Index: kernel/generic/src/cap/cap.c
===================================================================
--- kernel/generic/src/cap/cap.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/cap/cap.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -92,5 +92,5 @@
 {
 	cap_t *cap = hash_table_get_inst(item, cap_t, caps_link);
-	return hash_mix(cap->handle);
+	return hash_mix(CAP_HANDLE_RAW(cap->handle));
 }
 
@@ -98,5 +98,5 @@
 {
 	cap_handle_t *handle = (cap_handle_t *) key;
-	return hash_mix(*handle);
+	return hash_mix(CAP_HANDLE_RAW(*handle));
 }
 
@@ -224,5 +224,6 @@
 	assert(mutex_locked(&task->cap_info->lock));
 
-	if ((handle < CAPS_START) || (handle > CAPS_LAST))
+	if ((CAP_HANDLE_RAW(handle) < CAPS_START) ||
+	    (CAP_HANDLE_RAW(handle) > CAPS_LAST))
 		return NULL;
 	ht_link_t *link = hash_table_find(&task->cap_info->caps, &handle);
@@ -329,6 +330,6 @@
 void cap_free(task_t *task, cap_handle_t handle)
 {
-	assert(handle >= CAPS_START);
-	assert(handle <= CAPS_LAST);
+	assert(CAP_HANDLE_RAW(handle) >= CAPS_START);
+	assert(CAP_HANDLE_RAW(handle) <= CAPS_LAST);
 
 	mutex_lock(&task->cap_info->lock);
@@ -338,5 +339,5 @@
 
 	hash_table_remove_item(&task->cap_info->caps, &cap->caps_link);
-	ra_free(task->cap_info->handles, handle, 1);
+	ra_free(task->cap_info->handles, CAP_HANDLE_RAW(handle), 1);
 	slab_free(cap_cache, cap);
 	mutex_unlock(&task->cap_info->lock);
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/ipc.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -910,5 +910,5 @@
 	mutex_lock(&phone->lock);
 	if (phone->state != IPC_PHONE_FREE) {
-		printf("%-11d %7" PRIun " ", cap->handle,
+		printf("%-11d %7" PRIun " ", (int) CAP_HANDLE_RAW(cap->handle),
 		    atomic_get(&phone->active_calls));
 
Index: kernel/generic/src/ipc/ipcrsc.c
===================================================================
--- kernel/generic/src/ipc/ipcrsc.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/ipcrsc.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -157,5 +157,5 @@
  * @return  An error code if a new capability cannot be allocated.
  */
-errno_t phone_alloc(task_t *task, bool publish, cap_handle_t *phandle,
+errno_t phone_alloc(task_t *task, bool publish, cap_phone_handle_t *phandle,
     kobject_t **kobject)
 {
@@ -199,5 +199,5 @@
  *
  */
-void phone_dealloc(cap_handle_t handle)
+void phone_dealloc(cap_phone_handle_t handle)
 {
 	kobject_t *kobj = cap_unpublish(TASK, handle, KOBJECT_TYPE_PHONE);
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/irq.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -314,5 +314,5 @@
  */
 errno_t ipc_irq_subscribe(answerbox_t *box, inr_t inr, sysarg_t imethod,
-    irq_code_t *ucode, cap_handle_t *uspace_handle)
+    irq_code_t *ucode, cap_irq_handle_t *uspace_handle)
 {
 	if ((inr < 0) || (inr > last_inr))
@@ -390,5 +390,5 @@
  *
  */
-errno_t ipc_irq_unsubscribe(answerbox_t *box, int handle)
+errno_t ipc_irq_unsubscribe(answerbox_t *box, cap_irq_handle_t handle)
 {
 	kobject_t *kobj = cap_unpublish(TASK, handle, KOBJECT_TYPE_IRQ);
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/kbox.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -210,5 +210,5 @@
  *
  */
-errno_t ipc_connect_kbox(task_id_t taskid, cap_handle_t *out_phone)
+errno_t ipc_connect_kbox(task_id_t taskid, cap_phone_handle_t *out_phone)
 {
 	irq_spinlock_lock(&tasks_lock, true);
@@ -252,5 +252,5 @@
 
 	/* Allocate a new phone. */
-	cap_handle_t phone_handle;
+	cap_phone_handle_t phone_handle;
 	errno_t rc = phone_alloc(TASK, true, &phone_handle, NULL);
 	if (rc != EOK) {
Index: kernel/generic/src/ipc/ops/conctmeto.c
===================================================================
--- kernel/generic/src/ipc/ops/conctmeto.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/ops/conctmeto.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -46,5 +46,5 @@
 	 * That will be done once the phone is connected.
 	 */
-	cap_handle_t phone_handle;
+	cap_phone_handle_t phone_handle;
 	kobject_t *phone_obj;
 	errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj);
@@ -58,5 +58,5 @@
 
 	/* Remember the handle */
-	call->priv = phone_handle;
+	call->priv = CAP_HANDLE_RAW(phone_handle);
 
 	return EOK;
@@ -65,7 +65,7 @@
 static errno_t request_forget(call_t *call)
 {
-	cap_handle_t phone_handle = (cap_handle_t) call->priv;
+	cap_phone_handle_t phone_handle = (cap_handle_t) call->priv;
 
-	if (phone_handle < 0)
+	if (CAP_HANDLE_RAW(phone_handle) < 0)
 		return EOK;
 
@@ -103,9 +103,9 @@
 static errno_t answer_process(call_t *answer)
 {
-	cap_handle_t phone_handle = (cap_handle_t) answer->priv;
+	cap_phone_handle_t phone_handle = (cap_handle_t) answer->priv;
 	phone_t *phone = (phone_t *) IPC_GET_ARG5(answer->data);
 
 	if (IPC_GET_RETVAL(answer->data)) {
-		if (phone_handle >= 0) {
+		if (CAP_HANDLE_RAW(phone_handle) >= 0) {
 			/*
 			 * Cleanup the unpublished capability and drop
@@ -123,5 +123,5 @@
 		cap_publish(TASK, phone_handle, phone->kobject);
 
-		IPC_SET_ARG5(answer->data, phone_handle);
+		IPC_SET_ARG5(answer->data, CAP_HANDLE_RAW(phone_handle));
 	}
 
Index: kernel/generic/src/ipc/ops/concttome.c
===================================================================
--- kernel/generic/src/ipc/ops/concttome.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/ops/concttome.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -42,9 +42,10 @@
 static int request_process(call_t *call, answerbox_t *box)
 {
-	cap_handle_t phone_handle;
+	cap_phone_handle_t phone_handle;
 	kobject_t *phone_obj;
 	errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj);
 	call->priv = (sysarg_t) phone_obj;
-	IPC_SET_ARG5(call->data, (rc == EOK) ? phone_handle : -1);
+	IPC_SET_ARG5(call->data,
+	    (rc == EOK) ? CAP_HANDLE_RAW(phone_handle) : CAP_NIL);
 	return 0;
 }
@@ -52,8 +53,8 @@
 static errno_t answer_cleanup(call_t *answer, ipc_data_t *olddata)
 {
-	cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
+	cap_phone_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
 	kobject_t *phone_obj = (kobject_t *) answer->priv;
 
-	if (phone_handle >= 0) {
+	if (CAP_HANDLE_VALID(phone_handle)) {
 		kobject_put(phone_obj);
 		cap_free(TASK, phone_handle);
@@ -65,5 +66,5 @@
 static errno_t answer_preprocess(call_t *answer, ipc_data_t *olddata)
 {
-	cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
+	cap_phone_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
 	kobject_t *phone_obj = (kobject_t *) answer->priv;
 
@@ -71,5 +72,5 @@
 		/* The connection was not accepted */
 		answer_cleanup(answer, olddata);
-	} else if (phone_handle >= 0) {
+	} else if (CAP_HANDLE_VALID(phone_handle)) {
 		/*
 		 * The connection was accepted
Index: kernel/generic/src/ipc/ops/stchngath.c
===================================================================
--- kernel/generic/src/ipc/ops/stchngath.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/ops/stchngath.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -45,6 +45,6 @@
 	task_t *other_task_s;
 
-	kobject_t *sender_obj = kobject_get(TASK, IPC_GET_ARG5(call->data),
-	    KOBJECT_TYPE_PHONE);
+	kobject_t *sender_obj = kobject_get(TASK,
+	    (cap_handle_t) IPC_GET_ARG5(call->data), KOBJECT_TYPE_PHONE);
 	if (!sender_obj)
 		return ENOENT;
@@ -78,5 +78,6 @@
 
 		kobject_t *recipient_obj = kobject_get(TASK,
-		    IPC_GET_ARG1(answer->data), KOBJECT_TYPE_PHONE);
+		    (cap_handle_t) IPC_GET_ARG1(answer->data),
+		    KOBJECT_TYPE_PHONE);
 		if (!recipient_obj) {
 			IPC_SET_RETVAL(answer->data, ENOENT);
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/ipc/sysipc.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -271,5 +271,6 @@
  *
  */
-errno_t ipc_req_internal(cap_handle_t handle, ipc_data_t *data, sysarg_t priv)
+errno_t
+ipc_req_internal(cap_phone_handle_t handle, ipc_data_t *data, sysarg_t priv)
 {
 	kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE);
@@ -362,5 +363,5 @@
  *
  */
-sys_errno_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod,
+sys_errno_t sys_ipc_call_async_fast(cap_phone_handle_t handle, sysarg_t imethod,
     sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t label)
 {
@@ -409,5 +410,5 @@
  *
  */
-sys_errno_t sys_ipc_call_async_slow(sysarg_t handle, ipc_data_t *data,
+sys_errno_t sys_ipc_call_async_slow(cap_phone_handle_t handle, ipc_data_t *data,
     sysarg_t label)
 {
@@ -466,7 +467,7 @@
  *
  */
-static sys_errno_t sys_ipc_forward_common(sysarg_t chandle, sysarg_t phandle,
-    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
-    sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow)
+static sys_errno_t sys_ipc_forward_common(cap_call_handle_t chandle,
+    cap_phone_handle_t phandle, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow)
 {
 	kobject_t *ckobj = cap_unpublish(TASK, chandle, KOBJECT_TYPE_CALL);
@@ -506,5 +507,6 @@
 		if (method_is_system(IPC_GET_IMETHOD(call->data))) {
 			if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME)
-				phone_dealloc(IPC_GET_ARG5(call->data));
+				phone_dealloc((cap_phone_handle_t)
+				    IPC_GET_ARG5(call->data));
 
 			IPC_SET_ARG1(call->data, imethod);
@@ -577,6 +579,7 @@
  *
  */
-sys_errno_t sys_ipc_forward_fast(sysarg_t chandle, sysarg_t phandle,
-    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
+sys_errno_t sys_ipc_forward_fast(cap_call_handle_t chandle,
+    cap_phone_handle_t phandle, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    unsigned int mode)
 {
 	return sys_ipc_forward_common(chandle, phandle, imethod, arg1, arg2, 0,
@@ -601,6 +604,6 @@
  *
  */
-sys_errno_t sys_ipc_forward_slow(sysarg_t chandle, sysarg_t phandle,
-    ipc_data_t *data, unsigned int mode)
+sys_errno_t sys_ipc_forward_slow(cap_call_handle_t chandle,
+    cap_phone_handle_t phandle, ipc_data_t *data, unsigned int mode)
 {
 	ipc_data_t newdata;
@@ -631,6 +634,6 @@
  *
  */
-sys_errno_t sys_ipc_answer_fast(sysarg_t chandle, sysarg_t retval, sysarg_t arg1,
-    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
+sys_errno_t sys_ipc_answer_fast(cap_call_handle_t chandle, sysarg_t retval,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
 	kobject_t *kobj = cap_unpublish(TASK, chandle, KOBJECT_TYPE_CALL);
@@ -678,5 +681,5 @@
  *
  */
-sys_errno_t sys_ipc_answer_slow(sysarg_t chandle, ipc_data_t *data)
+sys_errno_t sys_ipc_answer_slow(cap_call_handle_t chandle, ipc_data_t *data)
 {
 	kobject_t *kobj = cap_unpublish(TASK, chandle, KOBJECT_TYPE_CALL);
@@ -722,5 +725,5 @@
  *
  */
-sys_errno_t sys_ipc_hangup(sysarg_t handle)
+sys_errno_t sys_ipc_hangup(cap_phone_handle_t handle)
 {
 	kobject_t *kobj = cap_unpublish(TASK, handle, KOBJECT_TYPE_PHONE);
@@ -800,5 +803,5 @@
 		goto restart;
 
-	cap_handle_t handle;
+	cap_handle_t handle = CAP_NIL;
 	errno_t rc = cap_alloc(TASK, &handle);
 	if (rc != EOK) {
@@ -821,5 +824,5 @@
 
 error:
-	if (handle >= 0)
+	if (CAP_HANDLE_VALID(handle))
 		cap_free(TASK, handle);
 
@@ -861,5 +864,5 @@
  * @param ucode   Uspace pointer to the top-half pseudocode.
  *
- * @param[out] uspace_handle  Uspace pointer to IRQ kernel object capability
+ * @param[out] uspace_handle  Uspace pointer to IRQ capability handle
  *
  * @return EPERM
@@ -867,6 +870,6 @@
  *
  */
-sys_errno_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode,
-	cap_handle_t *uspace_handle)
+sys_errno_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod,
+    irq_code_t *ucode, cap_irq_handle_t *uspace_handle)
 {
 	if (!(perm_get(TASK) & PERM_IRQ_REG))
@@ -878,16 +881,15 @@
 /** Disconnect an IRQ handler from a task.
  *
- * @param inr   IRQ number.
- * @param devno Device number.
+ * @param handle  IRQ capability handle.
  *
  * @return Zero on success or EPERM on error.
  *
  */
-sys_errno_t sys_ipc_irq_unsubscribe(sysarg_t cap)
+sys_errno_t sys_ipc_irq_unsubscribe(cap_irq_handle_t handle)
 {
 	if (!(perm_get(TASK) & PERM_IRQ_REG))
 		return EPERM;
 
-	ipc_irq_unsubscribe(&TASK->answerbox, cap);
+	ipc_irq_unsubscribe(&TASK->answerbox, handle);
 
 	return 0;
@@ -899,9 +901,10 @@
  *
  */
-sys_errno_t sys_ipc_connect_kbox(task_id_t *uspace_taskid, cap_handle_t *uspace_phone)
+sys_errno_t sys_ipc_connect_kbox(task_id_t *uspace_taskid,
+    cap_phone_handle_t *uspace_phone)
 {
 #ifdef CONFIG_UDEBUG
 	task_id_t taskid;
-	cap_handle_t phone;
+	cap_phone_handle_t phone;
 
 	errno_t rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(task_id_t));
Index: kernel/generic/src/mm/backend_user.c
===================================================================
--- kernel/generic/src/mm/backend_user.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/mm/backend_user.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -131,5 +131,5 @@
 		log(LF_USPACE, LVL_FATAL,
 		    "Page-in request for page %#" PRIxPTR
-		    " at pager %d failed with error %s.",
+		    " at pager %p failed with error %s.",
 		    upage, pager_info->pager, str_error_name(rc));
 		return AS_PF_FAULT;
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 67f11a04d9b9007cff6be59c182bd35c4f3ee076)
+++ kernel/generic/src/proc/task.c	(revision 3e242d25d5b49481f9f26ba4a66712daa6a48540)
@@ -245,5 +245,5 @@
 	if ((ipc_box_0) &&
 	    (container_check(ipc_box_0->task->container, task->container))) {
-		cap_handle_t phone_handle;
+		cap_phone_handle_t phone_handle;
 		errno_t rc = phone_alloc(task, true, &phone_handle, NULL);
 		if (rc != EOK) {
