Index: kernel/generic/src/ipc/event.c
===================================================================
--- kernel/generic/src/ipc/event.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/event.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -137,9 +137,7 @@
 			IPC_SET_ARG5(call->data, a5);
 			
-			ipl_t ipl = interrupts_disable();
-			spinlock_lock(&events[evno].answerbox->irq_lock);
+			irq_spinlock_lock(&events[evno].answerbox->irq_lock, true);
 			list_append(&call->link, &events[evno].answerbox->irq_notifs);
-			spinlock_unlock(&events[evno].answerbox->irq_lock);
-			interrupts_restore(ipl);
+			irq_spinlock_unlock(&events[evno].answerbox->irq_lock, true);
 			
 			waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST);
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/ipc.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -66,5 +66,6 @@
 /** Initialize a call structure.
  *
- * @param call		Call structure to be initialized.
+ * @param call Call structure to be initialized.
+ *
  */
 static void _ipc_call_init(call_t *call)
@@ -77,21 +78,20 @@
 
 /** Allocate and initialize a call structure.
- * 
+ *
  * The call is initialized, so that the reply will be directed to
  * TASK->answerbox.
  *
- * @param flags		Parameters for slab_alloc (e.g FRAME_ATOMIC).
- *
- * @return		If flags permit it, return NULL, or initialized kernel
- *			call structure.
- */
-call_t *ipc_call_alloc(int flags)
-{
-	call_t *call;
-
-	call = slab_alloc(ipc_call_slab, flags);
+ * @param flags Parameters for slab_alloc (e.g FRAME_ATOMIC).
+ *
+ * @return If flags permit it, return NULL, or initialized kernel
+ *         call structure.
+ *
+ */
+call_t *ipc_call_alloc(unsigned int flags)
+{
+	call_t *call = slab_alloc(ipc_call_slab, flags);
 	if (call)
 		_ipc_call_init(call);
-
+	
 	return call;
 }
@@ -99,5 +99,6 @@
 /** Deallocate a call structure.
  *
- * @param call		Call structure to be freed.
+ * @param call Call structure to be freed.
+ *
  */
 void ipc_call_free(call_t *call)
@@ -111,11 +112,12 @@
 /** Initialize an answerbox structure.
  *
- * @param box		Answerbox structure to be initialized.
- * @param task		Task to which the answerbox belongs.
+ * @param box  Answerbox structure to be initialized.
+ * @param task Task to which the answerbox belongs.
+ *
  */
 void ipc_answerbox_init(answerbox_t *box, task_t *task)
 {
-	spinlock_initialize(&box->lock, "ipc_box_lock");
-	spinlock_initialize(&box->irq_lock, "ipc_box_irqlock");
+	irq_spinlock_initialize(&box->lock, "ipc.box.lock");
+	irq_spinlock_initialize(&box->irq_lock, "ipc.box.irqlock");
 	waitq_initialize(&box->wq);
 	link_initialize(&box->sync_box_link);
@@ -131,18 +133,19 @@
 /** Connect a phone to an answerbox.
  *
- * @param phone		Initialized phone structure.
- * @param box		Initialized answerbox structure.
+ * @param phone Initialized phone structure.
+ * @param box   Initialized answerbox structure.
+ *
  */
 void ipc_phone_connect(phone_t *phone, answerbox_t *box)
 {
 	mutex_lock(&phone->lock);
-
+	
 	phone->state = IPC_PHONE_CONNECTED;
 	phone->callee = box;
-
-	spinlock_lock(&box->lock);
+	
+	irq_spinlock_lock(&box->lock, true);
 	list_append(&phone->link, &box->connected_phones);
-	spinlock_unlock(&box->lock);
-
+	irq_spinlock_unlock(&box->lock, true);
+	
 	mutex_unlock(&phone->lock);
 }
@@ -150,5 +153,6 @@
 /** Initialize a phone structure.
  *
- * @param phone		Phone structure to be initialized.
+ * @param phone Phone structure to be initialized.
+ *
  */
 void ipc_phone_init(phone_t *phone)
@@ -162,47 +166,41 @@
 /** Helper function to facilitate synchronous calls.
  *
- * @param phone		Destination kernel phone structure.
- * @param request	Call structure with request.
- *
- * @return		EOK on success or EINTR if the sleep was interrupted.
+ * @param phone   Destination kernel phone structure.
+ * @param request Call structure with request.
+ *
+ * @return EOK on success or EINTR if the sleep was interrupted.
+ *
  */
 int ipc_call_sync(phone_t *phone, call_t *request)
 {
-	answerbox_t *sync_box; 
-	ipl_t ipl;
-
-	sync_box = slab_alloc(ipc_answerbox_slab, 0);
+	answerbox_t *sync_box = slab_alloc(ipc_answerbox_slab, 0);
 	ipc_answerbox_init(sync_box, TASK);
-
+	
 	/*
 	 * Put the answerbox on the TASK's list of synchronous answerboxes so
 	 * that it can be cleaned up if the call is interrupted.
 	 */
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	irq_spinlock_lock(&TASK->lock, true);
 	list_append(&sync_box->sync_box_link, &TASK->sync_box_head);
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	irq_spinlock_unlock(&TASK->lock, true);
+	
 	/* We will receive data in a special box. */
 	request->callerbox = sync_box;
-
+	
 	ipc_call(phone, request);
 	if (!ipc_wait_for_call(sync_box, SYNCH_NO_TIMEOUT,
 	    SYNCH_FLAGS_INTERRUPTIBLE)) {
-	    	/* The answerbox and the call will be freed by ipc_cleanup(). */
+		/* The answerbox and the call will be freed by ipc_cleanup(). */
 		return EINTR;
 	}
-
+	
 	/*
 	 * The answer arrived without interruption so we can remove the
 	 * answerbox from the TASK's list of synchronous answerboxes.
 	 */
-	(void) interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	irq_spinlock_lock(&TASK->lock, true);
 	list_remove(&sync_box->sync_box_link);
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	irq_spinlock_unlock(&TASK->lock, true);
+	
 	slab_free(ipc_answerbox_slab, sync_box);
 	return EOK;
@@ -211,6 +209,7 @@
 /** Answer a message which was not dispatched and is not listed in any queue.
  *
- * @param call		Call structure to be answered.
- * @param selflocked	If true, then TASK->answebox is locked.
+ * @param call       Call structure to be answered.
+ * @param selflocked If true, then TASK->answebox is locked.
+ *
  */
 static void _ipc_answer_free_call(call_t *call, bool selflocked)
@@ -218,15 +217,12 @@
 	answerbox_t *callerbox = call->callerbox;
 	bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
-	ipl_t ipl;
-
+	
 	/* Count sent answer */
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	irq_spinlock_lock(&TASK->lock, true);
 	TASK->ipc_info.answer_sent++;
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	irq_spinlock_unlock(&TASK->lock, true);
+	
 	call->flags |= IPC_CALL_ANSWERED;
-
+	
 	if (call->flags & IPC_CALL_FORWARDED) {
 		if (call->caller_phone) {
@@ -235,10 +231,13 @@
 		}
 	}
-
+	
 	if (do_lock)
-		spinlock_lock(&callerbox->lock);
+		irq_spinlock_lock(&callerbox->lock, true);
+	
 	list_append(&call->link, &callerbox->answers);
+	
 	if (do_lock)
-		spinlock_unlock(&callerbox->lock);
+		irq_spinlock_unlock(&callerbox->lock, true);
+	
 	waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
 }
@@ -246,13 +245,15 @@
 /** Answer a message which is in a callee queue.
  *
- * @param box		Answerbox that is answering the message.
- * @param call		Modified request that is being sent back.
+ * @param box  Answerbox that is answering the message.
+ * @param call Modified request that is being sent back.
+ *
  */
 void ipc_answer(answerbox_t *box, call_t *call)
 {
 	/* Remove from active box */
-	spinlock_lock(&box->lock);
+	irq_spinlock_lock(&box->lock, true);
 	list_remove(&call->link);
-	spinlock_unlock(&box->lock);
+	irq_spinlock_unlock(&box->lock, true);
+	
 	/* Send back answer */
 	_ipc_answer_free_call(call, false);
@@ -264,7 +265,8 @@
  * message and sending it as a normal answer.
  *
- * @param phone		Phone structure the call should appear to come from.
- * @param call		Call structure to be answered.
- * @param err		Return value to be used for the answer.
+ * @param phone Phone structure the call should appear to come from.
+ * @param call  Call structure to be answered.
+ * @param err   Return value to be used for the answer.
+ *
  */
 void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)
@@ -278,27 +280,25 @@
 /** Unsafe unchecking version of ipc_call.
  *
- * @param phone		Phone structure the call comes from.
- * @param box		Destination answerbox structure.
- * @param call		Call structure with request.
+ * @param phone Phone structure the call comes from.
+ * @param box   Destination answerbox structure.
+ * @param call  Call structure with request.
+ *
  */
 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
 {
-	ipl_t ipl;
-
 	/* Count sent ipc call */
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	irq_spinlock_lock(&TASK->lock, true);
 	TASK->ipc_info.call_sent++;
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	irq_spinlock_unlock(&TASK->lock, true);
+	
 	if (!(call->flags & IPC_CALL_FORWARDED)) {
 		atomic_inc(&phone->active_calls);
 		call->data.phone = phone;
 	}
-
-	spinlock_lock(&box->lock);
+	
+	irq_spinlock_lock(&box->lock, true);
 	list_append(&call->link, &box->calls);
-	spinlock_unlock(&box->lock);
+	irq_spinlock_unlock(&box->lock, true);
+	
 	waitq_wakeup(&box->wq, WAKEUP_FIRST);
 }
@@ -306,14 +306,13 @@
 /** Send an asynchronous request using a phone to an answerbox.
  *
- * @param phone		Phone structure the call comes from and which is
- *			connected to the destination answerbox.
- * @param call		Call structure with request.
- *
- * @return		Return 0 on success, ENOENT on error.
+ * @param phone Phone structure the call comes from and which is
+ *              connected to the destination answerbox.
+ * @param call  Call structure with request.
+ *
+ * @return Return 0 on success, ENOENT on error.
+ *
  */
 int ipc_call(phone_t *phone, call_t *call)
 {
-	answerbox_t *box;
-
 	mutex_lock(&phone->lock);
 	if (phone->state != IPC_PHONE_CONNECTED) {
@@ -328,7 +327,9 @@
 				ipc_backsend_err(phone, call, ENOENT);
 		}
+		
 		return ENOENT;
 	}
-	box = phone->callee;
+	
+	answerbox_t *box = phone->callee;
 	_ipc_call(phone, box, call);
 	
@@ -342,14 +343,12 @@
  * lazily later.
  *
- * @param phone		Phone structure to be hung up.
- *              
- * @return		Return 0 if the phone is disconnected.
- *			Return -1 if the phone was already disconnected.
+ * @param phone Phone structure to be hung up.
+ *
+ * @return 0 if the phone is disconnected.
+ * @return -1 if the phone was already disconnected.
+ *
  */
 int ipc_phone_hangup(phone_t *phone)
 {
-	answerbox_t *box;
-	call_t *call;
-	
 	mutex_lock(&phone->lock);
 	if (phone->state == IPC_PHONE_FREE ||
@@ -359,20 +358,21 @@
 		return -1;
 	}
-	box = phone->callee;
+	
+	answerbox_t *box = phone->callee;
 	if (phone->state != IPC_PHONE_SLAMMED) {
 		/* Remove myself from answerbox */
-		spinlock_lock(&box->lock);
+		irq_spinlock_lock(&box->lock, true);
 		list_remove(&phone->link);
-		spinlock_unlock(&box->lock);
-
-		call = ipc_call_alloc(0);
+		irq_spinlock_unlock(&box->lock, true);
+		
+		call_t *call = ipc_call_alloc(0);
 		IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
 		call->flags |= IPC_CALL_DISCARD_ANSWER;
 		_ipc_call(phone, box, call);
 	}
-
+	
 	phone->state = IPC_PHONE_HUNGUP;
 	mutex_unlock(&phone->lock);
-
+	
 	return 0;
 }
@@ -380,30 +380,26 @@
 /** Forwards call from one answerbox to another one.
  *
- * @param call		Call structure to be redirected.
- * @param newphone	Phone structure to target answerbox.
- * @param oldbox	Old answerbox structure.
- * @param mode		Flags that specify mode of the forward operation.
- *
- * @return		Return 0 if forwarding succeeded or an error code if
- *			there was error.
- * 
+ * @param call     Call structure to be redirected.
+ * @param newphone Phone structure to target answerbox.
+ * @param oldbox   Old answerbox structure.
+ * @param mode     Flags that specify mode of the forward operation.
+ *
+ * @return 0 if forwarding succeeded or an error code if
+ *         there was an error.
+ *
  * The return value serves only as an information for the forwarder,
  * the original caller is notified automatically with EFORWARD.
- */
-int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode)
-{
-	ipl_t ipl;
-
+ *
+ */
+int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox,
+    unsigned int mode)
+{
 	/* Count forwarded calls */
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	irq_spinlock_lock(&TASK->lock, true);
 	TASK->ipc_info.forwarded++;
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
-	spinlock_lock(&oldbox->lock);
+	irq_spinlock_pass(&TASK->lock, &oldbox->lock);
 	list_remove(&call->link);
-	spinlock_unlock(&oldbox->lock);
-
+	irq_spinlock_unlock(&oldbox->lock, true);
+	
 	if (mode & IPC_FF_ROUTE_FROM_ME) {
 		if (!call->caller_phone)
@@ -411,5 +407,5 @@
 		call->data.phone = newphone;
 	}
-
+	
 	return ipc_call(newphone, call);
 }
@@ -418,24 +414,25 @@
 /** Wait for a phone call.
  *
- * @param box		Answerbox expecting the call.
- * @param usec		Timeout in microseconds. See documentation for
- *			waitq_sleep_timeout() for decription of its special
- *			meaning.
- * @param flags		Select mode of sleep operation. See documentation for
- *			waitq_sleep_timeout() for description of its special
- *			meaning.
- * @return 		Recived call structure or NULL.
- * 
+ * @param box   Answerbox expecting the call.
+ * @param usec  Timeout in microseconds. See documentation for
+ *              waitq_sleep_timeout() for decription of its special
+ *              meaning.
+ * @param flags Select mode of sleep operation. See documentation for
+ *              waitq_sleep_timeout() for description of its special
+ *              meaning.
+ *
+ * @return Recived call structure or NULL.
+ *
  * To distinguish between a call and an answer, have a look at call->flags.
- */
-call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags)
+ *
+ */
+call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, unsigned int flags)
 {
 	call_t *request;
-	ipl_t ipl;
 	uint64_t irq_cnt = 0;
 	uint64_t answer_cnt = 0;
 	uint64_t call_cnt = 0;
 	int rc;
-
+	
 restart:
 	rc = waitq_sleep_timeout(&box->wq, usec, flags);
@@ -443,21 +440,19 @@
 		return NULL;
 	
-	spinlock_lock(&box->lock);
+	irq_spinlock_lock(&box->lock, true);
 	if (!list_empty(&box->irq_notifs)) {
 		/* Count recieved IRQ notification */
-		irq_cnt++;	
-
-		ipl = interrupts_disable();
-		spinlock_lock(&box->irq_lock);
-
+		irq_cnt++;
+		
+		irq_spinlock_lock(&box->irq_lock, false);
+		
 		request = list_get_instance(box->irq_notifs.next, call_t, link);
 		list_remove(&request->link);
-
-		spinlock_unlock(&box->irq_lock);
-		interrupts_restore(ipl);
+		
+		irq_spinlock_unlock(&box->irq_lock, false);
 	} else if (!list_empty(&box->answers)) {
 		/* Count recieved answer */
 		answer_cnt++;
-
+		
 		/* Handle asynchronous answers */
 		request = list_get_instance(box->answers.next, call_t, link);
@@ -467,25 +462,25 @@
 		/* Count recieved call */
 		call_cnt++;
-
+		
 		/* Handle requests */
 		request = list_get_instance(box->calls.next, call_t, link);
 		list_remove(&request->link);
+		
 		/* Append request to dispatch queue */
 		list_append(&request->link, &box->dispatched_calls);
 	} else {
 		/* This can happen regularly after ipc_cleanup */
-		spinlock_unlock(&box->lock);
+		irq_spinlock_unlock(&box->lock, true);
 		goto restart;
 	}
-	spinlock_unlock(&box->lock);
-	
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
+	
+	irq_spinlock_pass(&box->lock, &TASK->lock);
+	
 	TASK->ipc_info.irq_notif_recieved += irq_cnt;
 	TASK->ipc_info.answer_recieved += answer_cnt;
 	TASK->ipc_info.call_recieved += call_cnt;
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	
+	irq_spinlock_unlock(&TASK->lock, true);
+	
 	return request;
 }
@@ -493,16 +488,16 @@
 /** Answer all calls from list with EHANGUP answer.
  *
- * @param lst		Head of the list to be cleaned up.
+ * @param lst Head of the list to be cleaned up.
+ *
  */
 void ipc_cleanup_call_list(link_t *lst)
 {
-	call_t *call;
-
 	while (!list_empty(lst)) {
-		call = list_get_instance(lst->next, call_t, link);
+		call_t *call = list_get_instance(lst->next, call_t, link);
 		if (call->buffer)
 			free(call->buffer);
+		
 		list_remove(&call->link);
-
+		
 		IPC_SET_RETVAL(call->data, EHANGUP);
 		_ipc_answer_free_call(call, true);
@@ -512,7 +507,8 @@
 /** Disconnects all phones connected to an answerbox.
  *
- * @param box		Answerbox to disconnect phones from.
- * @param notify_box	If true, the answerbox will get a hangup message for
- *			each disconnected phone.
+ * @param box        Answerbox to disconnect phones from.
+ * @param notify_box If true, the answerbox will get a hangup message for
+ *                   each disconnected phone.
+ *
  */
 void ipc_answerbox_slam_phones(answerbox_t *box, bool notify_box)
@@ -520,19 +516,15 @@
 	phone_t *phone;
 	DEADLOCK_PROBE_INIT(p_phonelck);
-	ipl_t ipl;
-	call_t *call;
-
-	call = notify_box ? ipc_call_alloc(0) : NULL;
-
+	
+	call_t *call = notify_box ? ipc_call_alloc(0) : NULL;
+	
 	/* Disconnect all phones connected to our answerbox */
 restart_phones:
-	ipl = interrupts_disable();
-	spinlock_lock(&box->lock);
+	irq_spinlock_lock(&box->lock, true);
 	while (!list_empty(&box->connected_phones)) {
 		phone = list_get_instance(box->connected_phones.next,
 		    phone_t, link);
 		if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
-			spinlock_unlock(&box->lock);
-			interrupts_restore(ipl);
+			irq_spinlock_unlock(&box->lock, true);
 			DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
 			goto restart_phones;
@@ -541,13 +533,12 @@
 		/* Disconnect phone */
 		ASSERT(phone->state == IPC_PHONE_CONNECTED);
-
+		
 		list_remove(&phone->link);
 		phone->state = IPC_PHONE_SLAMMED;
-
+		
 		if (notify_box) {
 			mutex_unlock(&phone->lock);
-			spinlock_unlock(&box->lock);
-			interrupts_restore(ipl);
-
+			irq_spinlock_unlock(&box->lock, true);
+			
 			/*
 			 * Send one message to the answerbox for each
@@ -559,18 +550,17 @@
 			call->flags |= IPC_CALL_DISCARD_ANSWER;
 			_ipc_call(phone, box, call);
-
+			
 			/* Allocate another call in advance */
 			call = ipc_call_alloc(0);
-
+			
 			/* Must start again */
 			goto restart_phones;
 		}
-
+		
 		mutex_unlock(&phone->lock);
 	}
-
-	spinlock_unlock(&box->lock);
-	interrupts_restore(ipl);
-
+	
+	irq_spinlock_unlock(&box->lock, true);
+	
 	/* Free unused call */
 	if (call)
@@ -578,47 +568,45 @@
 }
 
-/** Cleans up all IPC communication of the current task.
+/** Clean up all IPC communication of the current task.
  *
  * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
  * have to change it as well if you want to cleanup other tasks than TASK.
+ *
  */
 void ipc_cleanup(void)
 {
-	int i;
-	call_t *call;
-	ipl_t ipl;
-
 	/* Disconnect all our phones ('ipc_phone_hangup') */
+	size_t i;
 	for (i = 0; i < IPC_MAX_PHONES; i++)
 		ipc_phone_hangup(&TASK->phones[i]);
-
+	
 	/* Unsubscribe from any event notifications. */
 	event_cleanup_answerbox(&TASK->answerbox);
-
+	
 	/* Disconnect all connected irqs */
 	ipc_irq_cleanup(&TASK->answerbox);
-
+	
 	/* Disconnect all phones connected to our regular answerbox */
 	ipc_answerbox_slam_phones(&TASK->answerbox, false);
-
+	
 #ifdef CONFIG_UDEBUG
 	/* Clean up kbox thread and communications */
 	ipc_kbox_cleanup();
 #endif
-
+	
 	/* Answer all messages in 'calls' and 'dispatched_calls' queues */
-	spinlock_lock(&TASK->answerbox.lock);
+	irq_spinlock_lock(&TASK->answerbox.lock, true);
 	ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
 	ipc_cleanup_call_list(&TASK->answerbox.calls);
-	spinlock_unlock(&TASK->answerbox.lock);
+	irq_spinlock_unlock(&TASK->answerbox.lock, true);
 	
 	/* Wait for all answers to interrupted synchronous calls to arrive */
-	ipl = interrupts_disable();
+	ipl_t ipl = interrupts_disable();
 	while (!list_empty(&TASK->sync_box_head)) {
 		answerbox_t *box = list_get_instance(TASK->sync_box_head.next,
 		    answerbox_t, sync_box_link);
-
+		
 		list_remove(&box->sync_box_link);
-		call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,
+		call_t *call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,
 		    SYNCH_FLAGS_NONE);
 		ipc_call_free(call);
@@ -626,10 +614,12 @@
 	}
 	interrupts_restore(ipl);
-
+	
 	/* Wait for all answers to asynchronous calls to arrive */
-	while (1) {
-		/* Go through all phones, until all are FREE... */
-		/* Locking not needed, no one else should modify
-		 * it, when we are in cleanup */
+	while (true) {
+		/*
+		 * Go through all phones, until they are all FREE
+		 * Locking is not needed, no one else should modify
+		 * it when we are in cleanup
+		 */
 		for (i = 0; i < IPC_MAX_PHONES; i++) {
 			if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
@@ -639,20 +629,26 @@
 			}
 			
-			/* Just for sure, we might have had some 
-			 * IPC_PHONE_CONNECTING phones */
+			/*
+			 * Just for sure, we might have had some
+			 * IPC_PHONE_CONNECTING phones
+			 */
 			if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
 				ipc_phone_hangup(&TASK->phones[i]);
-			/* If the hangup succeeded, it has sent a HANGUP 
+			
+			/*
+			 * If the hangup succeeded, it has sent a HANGUP
 			 * message, the IPC is now in HUNGUP state, we
-			 * wait for the reply to come */
+			 * wait for the reply to come
+			 */
 			
 			if (TASK->phones[i].state != IPC_PHONE_FREE)
 				break;
 		}
-		/* Voila, got into cleanup */
+		
+		/* Got into cleanup */
 		if (i == IPC_MAX_PHONES)
 			break;
 		
-		call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
+		call_t *call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
 		    SYNCH_FLAGS_NONE);
 		ASSERT((call->flags & IPC_CALL_ANSWERED) ||
@@ -666,10 +662,12 @@
 		if (!(call->flags & IPC_CALL_DISCARD_ANSWER))
 			atomic_dec(&TASK->active_calls);
+		
 		ipc_call_free(call);
 	}
 }
 
-
-/** Initilize IPC subsystem */
+/** Initilize IPC subsystem
+ *
+ */
 void ipc_init(void)
 {
@@ -680,30 +678,26 @@
 }
 
-
 /** List answerbox contents.
  *
- * @param taskid	Task ID.
+ * @param taskid Task ID.
+ *
  */
 void ipc_print_task(task_id_t taskid)
 {
-	task_t *task;
-	int i;
-	call_t *call;
-	link_t *tmp;
-	ipl_t ipl;
-	
-	ipl = interrupts_disable();
-	spinlock_lock(&tasks_lock);
-	task = task_find_by_id(taskid);
-	if (task) 
-		spinlock_lock(&task->lock);
-	spinlock_unlock(&tasks_lock);
+	irq_spinlock_lock(&tasks_lock, true);
+	task_t *task = task_find_by_id(taskid);
+	
 	if (!task) {
-		interrupts_restore(ipl);
+		irq_spinlock_unlock(&tasks_lock, true);
 		return;
 	}
-
+	
+	/* Hand-over-hand locking */
+	irq_spinlock_exchange(&tasks_lock, &task->lock);
+	
 	/* Print opened phones & details */
 	printf("PHONE:\n");
+	
+	size_t i;
 	for (i = 0; i < IPC_MAX_PHONES; i++) {
 		if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
@@ -711,6 +705,8 @@
 			continue;
 		}
+		
 		if (task->phones[i].state != IPC_PHONE_FREE) {
-			printf("%d: ", i);
+			printf("%" PRIs ": ", i);
+			
 			switch (task->phones[i].state) {
 			case IPC_PHONE_CONNECTING:
@@ -718,31 +714,35 @@
 				break;
 			case IPC_PHONE_CONNECTED:
-				printf("connected to: %p ", 
-				       task->phones[i].callee);
+				printf("connected to: %p ",
+				    task->phones[i].callee);
 				break;
 			case IPC_PHONE_SLAMMED:
 				printf("slammed by: %p ", 
-				       task->phones[i].callee);
+				    task->phones[i].callee);
 				break;
 			case IPC_PHONE_HUNGUP:
 				printf("hung up - was: %p ", 
-				       task->phones[i].callee);
+				    task->phones[i].callee);
 				break;
 			default:
 				break;
 			}
-			printf("active: %ld\n",
+			
+			printf("active: %" PRIun "\n",
 			    atomic_get(&task->phones[i].active_calls));
 		}
+		
 		mutex_unlock(&task->phones[i].lock);
 	}
-
-
+	
+	irq_spinlock_lock(&task->answerbox.lock, false);
+	
+	link_t *cur;
+	
 	/* Print answerbox - calls */
-	spinlock_lock(&task->answerbox.lock);
 	printf("ABOX - CALLS:\n");
-	for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls;
-	    tmp = tmp->next) {
-		call = list_get_instance(tmp, call_t, link);
+	for (cur = task->answerbox.calls.next; cur != &task->answerbox.calls;
+	    cur = cur->next) {
+		call_t *call = list_get_instance(cur, call_t, link);
 		printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun 
 		    " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
@@ -754,10 +754,11 @@
 		    call->flags);
 	}
-	/* Print answerbox - calls */
+	
+	/* Print answerbox - dispatched calls */
 	printf("ABOX - DISPATCHED CALLS:\n");
-	for (tmp = task->answerbox.dispatched_calls.next;
-	    tmp != &task->answerbox.dispatched_calls; 
-	    tmp = tmp->next) {
-		call = list_get_instance(tmp, call_t, link);
+	for (cur = task->answerbox.dispatched_calls.next;
+	    cur != &task->answerbox.dispatched_calls;
+	    cur = cur->next) {
+		call_t *call = list_get_instance(cur, call_t, link);
 		printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
 		    " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
@@ -769,10 +770,11 @@
 		    call->flags);
 	}
-	/* Print answerbox - calls */
+	
+	/* Print answerbox - answers */
 	printf("ABOX - ANSWERS:\n");
-	for (tmp = task->answerbox.answers.next;
-	    tmp != &task->answerbox.answers;
-	    tmp = tmp->next) {
-		call = list_get_instance(tmp, call_t, link);
+	for (cur = task->answerbox.answers.next;
+	    cur != &task->answerbox.answers;
+	    cur = cur->next) {
+		call_t *call = list_get_instance(cur, call_t, link);
 		printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
 		    " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
@@ -782,8 +784,7 @@
 		    call->flags);
 	}
-
-	spinlock_unlock(&task->answerbox.lock);
-	spinlock_unlock(&task->lock);
-	interrupts_restore(ipl);
+	
+	irq_spinlock_unlock(&task->answerbox.lock, false);
+	irq_spinlock_unlock(&task->lock, true);
 }
 
Index: kernel/generic/src/ipc/ipcrsc.c
===================================================================
--- kernel/generic/src/ipc/ipcrsc.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/ipcrsc.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -45,5 +45,5 @@
  * - hangup phone (the caller has hung up)
  * - hangup phone (the answerbox is exiting)
- * 
+ *
  * Locking strategy
  *
@@ -85,5 +85,5 @@
  *
  * Phone hangup
- * 
+ *
  * *** The caller hangs up (sys_ipc_hangup) ***
  * - The phone is disconnected (no more messages can be sent over this phone),
@@ -99,5 +99,5 @@
  *
  * Call forwarding
- * 
+ *
  * The call can be forwarded, so that the answer to call is passed directly
  * to the original sender. However, this poses special problems regarding 
@@ -114,5 +114,5 @@
  *
  * Cleanup strategy
- * 
+ *
  * 1) Disconnect all our phones ('ipc_phone_hangup').
  *
@@ -123,5 +123,5 @@
  *
  * 4) Wait for all async answers to arrive and dispose of them.
- * 
+ *
  */
 
@@ -137,19 +137,20 @@
  * @todo Some speedup (hash table?)
  *
- * @param callid	Userspace hash of the call. Currently it is the call
- *			structure kernel address.
- *
- * @return		NULL on not found, otherwise pointer to the call
- *			structure.
+ * @param callid Userspace hash of the call. Currently it is the call
+ *               structure kernel address.
+ *
+ * @return NULL on not found, otherwise pointer to the call
+ *         structure.
+ *
  */
 call_t *get_call(unative_t callid)
 {
 	link_t *lst;
-	call_t *call, *result = NULL;
-
-	spinlock_lock(&TASK->answerbox.lock);
+	call_t *result = NULL;
+	
+	irq_spinlock_lock(&TASK->answerbox.lock, true);
 	for (lst = TASK->answerbox.dispatched_calls.next;
 	    lst != &TASK->answerbox.dispatched_calls; lst = lst->next) {
-		call = list_get_instance(lst, call_t, link);
+		call_t *call = list_get_instance(lst, call_t, link);
 		if ((unative_t) call == callid) {
 			result = call;
@@ -157,5 +158,6 @@
 		}
 	}
-	spinlock_unlock(&TASK->answerbox.lock);
+	
+	irq_spinlock_unlock(&TASK->answerbox.lock, true);
 	return result;
 }
@@ -163,29 +165,31 @@
 /** Allocate new phone slot in the specified task.
  *
- * @param t		Task for which to allocate a new phone.
- *
- * @return		New phone handle or -1 if the phone handle limit is
- *			exceeded.
- */
-int phone_alloc(task_t *t)
-{
-	int i;
-
-	spinlock_lock(&t->lock);
+ * @param task Task for which to allocate a new phone.
+ *
+ * @return New phone handle or -1 if the phone handle limit is
+ *         exceeded.
+ *
+ */
+int phone_alloc(task_t *task)
+{
+	irq_spinlock_lock(&task->lock, true);
+	
+	size_t i;
 	for (i = 0; i < IPC_MAX_PHONES; i++) {
-		if (t->phones[i].state == IPC_PHONE_HUNGUP &&
-		    atomic_get(&t->phones[i].active_calls) == 0)
-			t->phones[i].state = IPC_PHONE_FREE;
-
-		if (t->phones[i].state == IPC_PHONE_FREE) {
-			t->phones[i].state = IPC_PHONE_CONNECTING;
+		if ((task->phones[i].state == IPC_PHONE_HUNGUP) &&
+		    (atomic_get(&task->phones[i].active_calls) == 0))
+			task->phones[i].state = IPC_PHONE_FREE;
+		
+		if (task->phones[i].state == IPC_PHONE_FREE) {
+			task->phones[i].state = IPC_PHONE_CONNECTING;
 			break;
 		}
 	}
-	spinlock_unlock(&t->lock);
-
+	
+	irq_spinlock_unlock(&task->lock, true);
+	
 	if (i == IPC_MAX_PHONES)
 		return -1;
-
+	
 	return i;
 }
@@ -193,5 +197,6 @@
 /** Mark a phone structure free.
  *
- * @param phone		Phone structure to be marked free.
+ * @param phone Phone structure to be marked free.
+ *
  */
 static void phone_deallocp(phone_t *phone)
@@ -199,5 +204,5 @@
 	ASSERT(phone->state == IPC_PHONE_CONNECTING);
 	
-	/* atomic operation */
+	/* Atomic operation */
 	phone->state = IPC_PHONE_FREE;
 }
@@ -207,5 +212,6 @@
  * All already sent messages will be correctly processed.
  *
- * @param phoneid	Phone handle of the phone to be freed.
+ * @param phoneid Phone handle of the phone to be freed.
+ *
  */
 void phone_dealloc(int phoneid)
@@ -216,10 +222,11 @@
 /** Connect phone to a given answerbox.
  *
- * @param phoneid 	Phone handle to be connected.
- * @param box		Answerbox to which to connect the phone handle.
+ * @param phoneid Phone handle to be connected.
+ * @param box     Answerbox to which to connect the phone handle.
  *
  * The procedure _enforces_ that the user first marks the phone
  * busy (e.g. via phone_alloc) and then connects the phone, otherwise
  * race condition may appear.
+ *
  */
 void phone_connect(int phoneid, answerbox_t *box)
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/irq.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -31,4 +31,5 @@
  * @{
  */
+
 /**
  * @file
@@ -67,4 +68,5 @@
  *   structure are finished. Because we hold the hash table lock, we prevent new
  *   IRQs from taking new references to the IRQ structure.
+ *
  */
 
@@ -81,5 +83,6 @@
 /** Free the top-half pseudocode.
  *
- * @param code		Pointer to the top-half pseudocode.
+ * @param code Pointer to the top-half pseudocode.
+ *
  */
 static void code_free(irq_code_t *code)
@@ -93,16 +96,13 @@
 /** Copy the top-half pseudocode from userspace into the kernel.
  *
- * @param ucode		Userspace address of the top-half pseudocode.
- *
- * @return		Kernel address of the copied pseudocode.
+ * @param ucode Userspace address of the top-half pseudocode.
+ *
+ * @return Kernel address of the copied pseudocode.
+ *
  */
 static irq_code_t *code_from_uspace(irq_code_t *ucode)
 {
-	irq_code_t *code;
-	irq_cmd_t *ucmds;
-	int rc;
-
-	code = malloc(sizeof(*code), 0);
-	rc = copy_from_uspace(code, ucode, sizeof(*code));
+	irq_code_t *code = malloc(sizeof(*code), 0);
+	int rc = copy_from_uspace(code, ucode, sizeof(*code));
 	if (rc != 0) {
 		free(code);
@@ -114,5 +114,6 @@
 		return NULL;
 	}
-	ucmds = code->cmds;
+	
+	irq_cmd_t *ucmds = code->cmds;
 	code->cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
 	rc = copy_from_uspace(code->cmds, ucmds,
@@ -123,5 +124,5 @@
 		return NULL;
 	}
-
+	
 	return code;
 }
@@ -141,8 +142,4 @@
     unative_t method, irq_code_t *ucode)
 {
-	ipl_t ipl;
-	irq_code_t *code;
-	irq_t *irq;
-	link_t *hlp;
 	unative_t key[] = {
 		(unative_t) inr,
@@ -150,16 +147,17 @@
 	};
 	
+	irq_code_t *code;
 	if (ucode) {
 		code = code_from_uspace(ucode);
 		if (!code)
 			return EBADMEM;
-	} else {
+	} else
 		code = NULL;
-	}
 	
 	/*
 	 * Allocate and populate the IRQ structure.
 	 */
-	irq = malloc(sizeof(irq_t), 0);
+	irq_t *irq = malloc(sizeof(irq_t), 0);
+	
 	irq_initialize(irq);
 	irq->devno = devno;
@@ -177,29 +175,30 @@
 	 * answerbox's list.
 	 */
-	ipl = interrupts_disable();
-	spinlock_lock(&irq_uspace_hash_table_lock);
-	hlp = hash_table_find(&irq_uspace_hash_table, key);
+	irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
+	
+	link_t *hlp = hash_table_find(&irq_uspace_hash_table, key);
 	if (hlp) {
-		irq_t *hirq __attribute__((unused))
-		    = hash_table_get_instance(hlp, irq_t, link);
+		irq_t *hirq = hash_table_get_instance(hlp, irq_t, link);
 		
 		/* hirq is locked */
-		spinlock_unlock(&hirq->lock);
+		irq_spinlock_unlock(&hirq->lock, false);
 		code_free(code);
-		spinlock_unlock(&irq_uspace_hash_table_lock);
+		irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
+		
 		free(irq);
-		interrupts_restore(ipl);
 		return EEXISTS;
 	}
 	
-	spinlock_lock(&irq->lock);  /* Not really necessary, but paranoid */
-	spinlock_lock(&box->irq_lock);
+	/* Locking is not really necessary, but paranoid */
+	irq_spinlock_lock(&irq->lock, false);
+	irq_spinlock_lock(&box->irq_lock, false);
+	
 	hash_table_insert(&irq_uspace_hash_table, key, &irq->link);
 	list_append(&irq->notif_cfg.link, &box->irq_head);
-	spinlock_unlock(&box->irq_lock);
-	spinlock_unlock(&irq->lock);
-	spinlock_unlock(&irq_uspace_hash_table_lock);
-	
-	interrupts_restore(ipl);
+	
+	irq_spinlock_unlock(&box->irq_lock, false);
+	irq_spinlock_unlock(&irq->lock, false);
+	irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
+	
 	return EOK;
 }
@@ -207,29 +206,27 @@
 /** Unregister task from IRQ notification.
  *
- * @param box		Answerbox associated with the notification.
- * @param inr		IRQ number.
- * @param devno		Device number.
+ * @param box   Answerbox associated with the notification.
+ * @param inr   IRQ number.
+ * @param devno Device number.
+ *
  */
 int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
 {
-	ipl_t ipl;
 	unative_t key[] = {
 		(unative_t) inr,
 		(unative_t) devno
 	};
-	link_t *lnk;
-	irq_t *irq;
-
-	ipl = interrupts_disable();
-	spinlock_lock(&irq_uspace_hash_table_lock);
-	lnk = hash_table_find(&irq_uspace_hash_table, key);
+	
+	irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
+	link_t *lnk = hash_table_find(&irq_uspace_hash_table, key);
 	if (!lnk) {
-		spinlock_unlock(&irq_uspace_hash_table_lock);
-		interrupts_restore(ipl);
+		irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
 		return ENOENT;
 	}
-	irq = hash_table_get_instance(lnk, irq_t, link);
+	
+	irq_t *irq = hash_table_get_instance(lnk, irq_t, link);
+	
 	/* irq is locked */
-	spinlock_lock(&box->irq_lock);
+	irq_spinlock_lock(&box->irq_lock, false);
 	
 	ASSERT(irq->notif_cfg.answerbox == box);
@@ -237,8 +234,8 @@
 	/* Free up the pseudo code and associated structures. */
 	code_free(irq->notif_cfg.code);
-
-	/* Remove the IRQ from the answerbox's list. */ 
+	
+	/* Remove the IRQ from the answerbox's list. */
 	list_remove(&irq->notif_cfg.link);
-
+	
 	/*
 	 * We need to drop the IRQ lock now because hash_table_remove() will try
@@ -248,19 +245,17 @@
 	 * the meantime.
 	 */
-	spinlock_unlock(&irq->lock);
-
+	irq_spinlock_unlock(&irq->lock, false);
+	
 	/* Remove the IRQ from the uspace IRQ hash table. */
 	hash_table_remove(&irq_uspace_hash_table, key, 2);
 	
-	spinlock_unlock(&irq_uspace_hash_table_lock);
-	spinlock_unlock(&box->irq_lock);
+	irq_spinlock_unlock(&box->irq_lock, false);
+	irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
 	
 	/* Free up the IRQ structure. */
 	free(irq);
 	
-	interrupts_restore(ipl);
 	return EOK;
 }
-
 
 /** Disconnect all IRQ notifications from an answerbox.
@@ -270,35 +265,32 @@
  * send notifications to it.
  *
- * @param box		Answerbox for which we want to carry out the cleanup.
+ * @param box Answerbox for which we want to carry out the cleanup.
+ *
  */
 void ipc_irq_cleanup(answerbox_t *box)
 {
-	ipl_t ipl;
-	
 loop:
-	ipl = interrupts_disable();
-	spinlock_lock(&irq_uspace_hash_table_lock);
-	spinlock_lock(&box->irq_lock);
+	irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
+	irq_spinlock_lock(&box->irq_lock, false);
 	
 	while (box->irq_head.next != &box->irq_head) {
-		link_t *cur = box->irq_head.next;
-		irq_t *irq;
 		DEADLOCK_PROBE_INIT(p_irqlock);
-		unative_t key[2];
-		
-		irq = list_get_instance(cur, irq_t, notif_cfg.link);
-		if (!spinlock_trylock(&irq->lock)) {
+		
+		irq_t *irq = list_get_instance(box->irq_head.next, irq_t,
+		    notif_cfg.link);
+		
+		if (!irq_spinlock_trylock(&irq->lock)) {
 			/*
 			 * Avoid deadlock by trying again.
 			 */
-			spinlock_unlock(&box->irq_lock);
-			spinlock_unlock(&irq_uspace_hash_table_lock);
-			interrupts_restore(ipl);
+			irq_spinlock_unlock(&box->irq_lock, false);
+			irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
 			DEADLOCK_PROBE(p_irqlock, DEADLOCK_THRESHOLD);
 			goto loop;
 		}
+		
+		unative_t key[2];
 		key[0] = irq->inr;
 		key[1] = irq->devno;
-		
 		
 		ASSERT(irq->notif_cfg.answerbox == box);
@@ -317,5 +309,5 @@
 		 * didn't drop the hash table lock in the meantime.
 		 */
-		spinlock_unlock(&irq->lock);
+		irq_spinlock_unlock(&irq->lock, false);
 		
 		/* Remove from the hash table. */
@@ -325,22 +317,22 @@
 	}
 	
-	spinlock_unlock(&box->irq_lock);
-	spinlock_unlock(&irq_uspace_hash_table_lock);
-	interrupts_restore(ipl);
+	irq_spinlock_unlock(&box->irq_lock, false);
+	irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
 }
 
 /** Add a call to the proper answerbox queue.
  *
- * Assume irq->lock is locked.
- *
- * @param irq		IRQ structure referencing the target answerbox.
- * @param call		IRQ notification call.
+ * Assume irq->lock is locked and interrupts disabled.
+ *
+ * @param irq  IRQ structure referencing the target answerbox.
+ * @param call IRQ notification call.
+ *
  */
 static void send_call(irq_t *irq, call_t *call)
 {
-	spinlock_lock(&irq->notif_cfg.answerbox->irq_lock);
+	irq_spinlock_lock(&irq->notif_cfg.answerbox->irq_lock, false);
 	list_append(&call->link, &irq->notif_cfg.answerbox->irq_notifs);
-	spinlock_unlock(&irq->notif_cfg.answerbox->irq_lock);
-		
+	irq_spinlock_unlock(&irq->notif_cfg.answerbox->irq_lock, false);
+	
 	waitq_wakeup(&irq->notif_cfg.answerbox->wq, WAKEUP_FIRST);
 }
@@ -348,16 +340,14 @@
 /** Apply the top-half pseudo code to find out whether to accept the IRQ or not.
  *
- * @param irq		IRQ structure.
- *
- * @return		IRQ_ACCEPT if the interrupt is accepted by the
- *			pseudocode. IRQ_DECLINE otherwise.
+ * @param irq IRQ structure.
+ *
+ * @return IRQ_ACCEPT if the interrupt is accepted by the
+ *         pseudocode, IRQ_DECLINE otherwise.
+ *
  */
 irq_ownership_t ipc_irq_top_half_claim(irq_t *irq)
 {
-	unsigned int i;
-	unative_t dstval;
 	irq_code_t *code = irq->notif_cfg.code;
-	unative_t *scratch = irq->notif_cfg.scratch;
-
+	uint32_t *scratch = irq->notif_cfg.scratch;
 	
 	if (!irq->notif_cfg.notify)
@@ -367,10 +357,13 @@
 		return IRQ_DECLINE;
 	
+	size_t i;
 	for (i = 0; i < code->cmdcount; i++) {
-		unsigned int srcarg = code->cmds[i].srcarg;
-		unsigned int dstarg = code->cmds[i].dstarg;
+		uint32_t dstval;
+		uintptr_t srcarg = code->cmds[i].srcarg;
+		uintptr_t dstarg = code->cmds[i].dstarg;
 		
 		if (srcarg >= IPC_CALL_LEN)
 			break;
+		
 		if (dstarg >= IPC_CALL_LEN)
 			break;
@@ -405,5 +398,5 @@
 			break;
 		case CMD_BTEST:
-			if (srcarg && dstarg) {
+			if ((srcarg) && (dstarg)) {
 				dstval = scratch[srcarg] & code->cmds[i].value;
 				scratch[dstarg] = dstval;
@@ -411,5 +404,5 @@
 			break;
 		case CMD_PREDICATE:
-			if (srcarg && !scratch[srcarg]) {
+			if ((srcarg) && (!scratch[srcarg])) {
 				i += code->cmds[i].value;
 				continue;
@@ -427,19 +420,17 @@
 }
 
-
 /* IRQ top-half handler.
  *
  * We expect interrupts to be disabled and the irq->lock already held.
  *
- * @param irq		IRQ structure.
+ * @param irq IRQ structure.
+ *
  */
 void ipc_irq_top_half_handler(irq_t *irq)
 {
 	ASSERT(irq);
-
+	
 	if (irq->notif_cfg.answerbox) {
-		call_t *call;
-
-		call = ipc_call_alloc(FRAME_ATOMIC);
+		call_t *call = ipc_call_alloc(FRAME_ATOMIC);
 		if (!call)
 			return;
@@ -448,5 +439,5 @@
 		/* Put a counter to the message */
 		call->priv = ++irq->notif_cfg.counter;
-
+		
 		/* Set up args */
 		IPC_SET_METHOD(call->data, irq->notif_cfg.method);
@@ -456,5 +447,5 @@
 		IPC_SET_ARG4(call->data, irq->notif_cfg.scratch[4]);
 		IPC_SET_ARG5(call->data, irq->notif_cfg.scratch[5]);
-
+		
 		send_call(irq, call);
 	}
@@ -463,28 +454,28 @@
 /** Send notification message.
  *
- * @param irq		IRQ structure.
- * @param a1		Driver-specific payload argument.
- * @param a2		Driver-specific payload argument.
- * @param a3		Driver-specific payload argument.
- * @param a4		Driver-specific payload argument.
- * @param a5		Driver-specific payload argument.
+ * @param irq IRQ structure.
+ * @param a1  Driver-specific payload argument.
+ * @param a2  Driver-specific payload argument.
+ * @param a3  Driver-specific payload argument.
+ * @param a4  Driver-specific payload argument.
+ * @param a5  Driver-specific payload argument.
+ *
  */
 void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3,
     unative_t a4, unative_t a5)
 {
-	call_t *call;
-
-	spinlock_lock(&irq->lock);
-
+	irq_spinlock_lock(&irq->lock, true);
+	
 	if (irq->notif_cfg.answerbox) {
-		call = ipc_call_alloc(FRAME_ATOMIC);
+		call_t *call = ipc_call_alloc(FRAME_ATOMIC);
 		if (!call) {
-			spinlock_unlock(&irq->lock);
+			irq_spinlock_unlock(&irq->lock, true);
 			return;
 		}
+		
 		call->flags |= IPC_CALL_NOTIF;
 		/* Put a counter to the message */
 		call->priv = ++irq->notif_cfg.counter;
-
+		
 		IPC_SET_METHOD(call->data, irq->notif_cfg.method);
 		IPC_SET_ARG1(call->data, a1);
@@ -496,5 +487,6 @@
 		send_call(irq, call);
 	}
-	spinlock_unlock(&irq->lock);
+	
+	irq_spinlock_unlock(&irq->lock, true);
 }
 
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/kbox.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -47,7 +47,5 @@
 void ipc_kbox_cleanup(void)
 {
-	bool have_kb_thread;
-
-	/* 
+	/*
 	 * Only hold kb.cleanup_lock while setting kb.finished -
 	 * this is enough.
@@ -56,12 +54,12 @@
 	TASK->kb.finished = true;
 	mutex_unlock(&TASK->kb.cleanup_lock);
-
-	have_kb_thread = (TASK->kb.thread != NULL);
-
+	
+	bool have_kb_thread = (TASK->kb.thread != NULL);
+	
 	/*
 	 * From now on nobody will try to connect phones or attach
 	 * kbox threads
 	 */
-
+	
 	/*
 	 * Disconnect all phones connected to our kbox. Passing true for
@@ -71,6 +69,6 @@
 	 */
 	ipc_answerbox_slam_phones(&TASK->kb.box, have_kb_thread);
-
-	/* 
+	
+	/*
 	 * If the task was being debugged, clean up debugging session.
 	 * This is necessarry as slamming the phones won't force
@@ -80,5 +78,5 @@
 	udebug_task_cleanup(TASK);
 	mutex_unlock(&TASK->udebug.lock);
-
+	
 	if (have_kb_thread) {
 		LOG("Join kb.thread.");
@@ -88,44 +86,40 @@
 		TASK->kb.thread = NULL;
 	}
-
+	
 	/* Answer all messages in 'calls' and 'dispatched_calls' queues. */
-	spinlock_lock(&TASK->kb.box.lock);
+	irq_spinlock_lock(&TASK->kb.box.lock, true);
 	ipc_cleanup_call_list(&TASK->kb.box.dispatched_calls);
 	ipc_cleanup_call_list(&TASK->kb.box.calls);
-	spinlock_unlock(&TASK->kb.box.lock);
+	irq_spinlock_unlock(&TASK->kb.box.lock, true);
 }
 
 /** Handle hangup message in kbox.
  *
- * @param call	The IPC_M_PHONE_HUNGUP call structure.
- * @param last	Output, the function stores @c true here if
- *		this was the last phone, @c false otherwise.
- **/
+ * @param call The IPC_M_PHONE_HUNGUP call structure.
+ * @param last Output, the function stores @c true here if
+ *             this was the last phone, @c false otherwise.
+ *
+ */
 static void kbox_proc_phone_hungup(call_t *call, bool *last)
 {
-	ipl_t ipl;
-
 	/* Was it our debugger, who hung up? */
 	if (call->sender == TASK->udebug.debugger) {
 		/* Terminate debugging session (if any). */
 		LOG("Terminate debugging session.");
-		ipl = interrupts_disable();
-		spinlock_lock(&TASK->lock);
+		irq_spinlock_lock(&TASK->lock, true);
 		udebug_task_cleanup(TASK);
-		spinlock_unlock(&TASK->lock);
-		interrupts_restore(ipl);
+		irq_spinlock_unlock(&TASK->lock, true);
 	} else {
 		LOG("Was not debugger.");
 	}
-
+	
 	LOG("Continue with hangup message.");
 	IPC_SET_RETVAL(call->data, 0);
 	ipc_answer(&TASK->kb.box, call);
-
+	
 	mutex_lock(&TASK->kb.cleanup_lock);
-
-	ipl = interrupts_disable();
-	spinlock_lock(&TASK->lock);
-	spinlock_lock(&TASK->kb.box.lock);
+	
+	irq_spinlock_lock(&TASK->lock, true);
+	irq_spinlock_lock(&TASK->kb.box.lock, false);
 	if (list_empty(&TASK->kb.box.connected_phones)) {
 		/*
@@ -133,5 +127,5 @@
 		 * gets freed and signal to the caller.
 		 */
-
+		
 		/* Only detach kbox thread unless already terminating. */
 		if (TASK->kb.finished == false) {
@@ -140,15 +134,13 @@
 			TASK->kb.thread = NULL;
 		}
-
+		
 		LOG("Phone list is empty.");
 		*last = true;
-	} else {
+	} else
 		*last = false;
-	}
-
-	spinlock_unlock(&TASK->kb.box.lock);
-	spinlock_unlock(&TASK->lock);
-	interrupts_restore(ipl);
-
+	
+	irq_spinlock_unlock(&TASK->kb.box.lock, true);
+	irq_spinlock_unlock(&TASK->lock, false);
+	
 	mutex_unlock(&TASK->kb.cleanup_lock);
 }
@@ -159,29 +151,27 @@
  * when all phones are disconnected from the kbox.
  *
- * @param arg	Ignored.
+ * @param arg Ignored.
+ *
  */
 static void kbox_thread_proc(void *arg)
 {
-	call_t *call;
-	bool done;
-
-	(void)arg;
+	(void) arg;
 	LOG("Starting.");
-	done = false;
-
+	bool done = false;
+	
 	while (!done) {
-		call = ipc_wait_for_call(&TASK->kb.box, SYNCH_NO_TIMEOUT,
+		call_t *call = ipc_wait_for_call(&TASK->kb.box, SYNCH_NO_TIMEOUT,
 			SYNCH_FLAGS_NONE);
-
+		
 		if (call == NULL)
-			continue;	/* Try again. */
-
+			continue;  /* Try again. */
+		
 		switch (IPC_GET_METHOD(call->data)) {
-
+		
 		case IPC_M_DEBUG_ALL:
 			/* Handle debug call. */
 			udebug_call_receive(call);
 			break;
-
+		
 		case IPC_M_PHONE_HUNGUP:
 			/*
@@ -192,5 +182,5 @@
 			kbox_proc_phone_hungup(call, &done);
 			break;
-
+		
 		default:
 			/* Ignore */
@@ -198,11 +188,10 @@
 		}
 	}
-
+	
 	LOG("Exiting.");
 }
 
 
-/**
- * Connect phone to a task kernel-box specified by id.
+/** Connect phone to a task kernel-box specified by id.
  *
  * Note that this is not completely atomic. For optimisation reasons, the task
@@ -211,68 +200,61 @@
  * cleanup code.
  *
- * @return 		Phone id on success, or negative error code.
+ * @return Phone id on success, or negative error code.
+ *
  */
 int ipc_connect_kbox(task_id_t taskid)
 {
-	int newphid;
-	task_t *ta;
-	thread_t *kb_thread;
-	ipl_t ipl;
-
-	ipl = interrupts_disable();
-	spinlock_lock(&tasks_lock);
-
-	ta = task_find_by_id(taskid);
-	if (ta == NULL) {
-		spinlock_unlock(&tasks_lock);
-		interrupts_restore(ipl);
+	irq_spinlock_lock(&tasks_lock, true);
+	
+	task_t *task = task_find_by_id(taskid);
+	if (task == NULL) {
+		irq_spinlock_unlock(&tasks_lock, true);
 		return ENOENT;
 	}
-
-	atomic_inc(&ta->refcount);
-
-	spinlock_unlock(&tasks_lock);
-	interrupts_restore(ipl);
-
-	mutex_lock(&ta->kb.cleanup_lock);
-
-	if (atomic_predec(&ta->refcount) == 0) {
-		mutex_unlock(&ta->kb.cleanup_lock);
-		task_destroy(ta);
+	
+	atomic_inc(&task->refcount);
+	
+	irq_spinlock_unlock(&tasks_lock, true);
+	
+	mutex_lock(&task->kb.cleanup_lock);
+	
+	if (atomic_predec(&task->refcount) == 0) {
+		mutex_unlock(&task->kb.cleanup_lock);
+		task_destroy(task);
 		return ENOENT;
 	}
-
-	if (ta->kb.finished != false) {
-		mutex_unlock(&ta->kb.cleanup_lock);
+	
+	if (task->kb.finished != false) {
+		mutex_unlock(&task->kb.cleanup_lock);
 		return EINVAL;
 	}
-
-	newphid = phone_alloc(TASK);
+	
+	int newphid = phone_alloc(TASK);
 	if (newphid < 0) {
-		mutex_unlock(&ta->kb.cleanup_lock);
+		mutex_unlock(&task->kb.cleanup_lock);
 		return ELIMIT;
 	}
-
+	
 	/* Connect the newly allocated phone to the kbox */
-	ipc_phone_connect(&TASK->phones[newphid], &ta->kb.box);
-
-	if (ta->kb.thread != NULL) {
-		mutex_unlock(&ta->kb.cleanup_lock);
+	ipc_phone_connect(&TASK->phones[newphid], &task->kb.box);
+	
+	if (task->kb.thread != NULL) {
+		mutex_unlock(&task->kb.cleanup_lock);
 		return newphid;
 	}
-
+	
 	/* Create a kbox thread */
-	kb_thread = thread_create(kbox_thread_proc, NULL, ta, 0,
+	thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task, 0,
 	    "kbox", false);
 	if (!kb_thread) {
-		mutex_unlock(&ta->kb.cleanup_lock);
+		mutex_unlock(&task->kb.cleanup_lock);
 		return ENOMEM;
 	}
-
-	ta->kb.thread = kb_thread;
+	
+	task->kb.thread = kb_thread;
 	thread_ready(kb_thread);
-
-	mutex_unlock(&ta->kb.cleanup_lock);
-
+	
+	mutex_unlock(&task->kb.cleanup_lock);
+	
 	return newphid;
 }
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision f173404146b4afb7af15c0a9783566536346757a)
+++ kernel/generic/src/ipc/sysipc.c	(revision c8e99bb315a5bcdd7baf9ad996e0c913004c1016)
@@ -56,11 +56,15 @@
  * requests.
  */
-#define DATA_XFER_LIMIT		(64 * 1024)
+#define DATA_XFER_LIMIT  (64 * 1024)
+
+#define STRUCT_TO_USPACE(dst, src)  copy_to_uspace((dst), (src), sizeof(*(src)))
 
 /** Get phone from the current task by ID.
  *
- * @param phoneid	Phone ID.
- * @param phone		Place to store pointer to phone.
- * @return		EOK on success, EINVAL if ID is invalid.
+ * @param phoneid Phone ID.
+ * @param phone   Place to store pointer to phone.
+ *
+ * @return EOK on success, EINVAL if ID is invalid.
+ *
  */
 static int phone_get(unative_t phoneid, phone_t **phone)
@@ -68,23 +72,22 @@
 	if (phoneid >= IPC_MAX_PHONES)
 		return EINVAL;
-
+	
 	*phone = &TASK->phones[phoneid];
 	return EOK;
 }
 
-#define STRUCT_TO_USPACE(dst, src)	copy_to_uspace(dst, src, sizeof(*(src)))
-
 /** Decide if the method is a system method.
  *
- * @param method	Method to be decided.
- *
- * @return		Return 1 if the method is a system method.
- *			Otherwise return 0.
- */
-static inline int method_is_system(unative_t method)
+ * @param method Method to be decided.
+ *
+ * @return true if the method is a system method.
+ *
+ */
+static inline bool method_is_system(unative_t method)
 {
 	if (method <= IPC_M_LAST_SYSTEM)
-		return 1;
-	return 0;
+		return true;
+	
+	return false;
 }
 
@@ -94,10 +97,10 @@
  *   it is useless
  *
- * @param method	Method to be decided.
- *
- * @return		Return 1 if the method is forwardable.
- *			Otherwise return 0.
- */
-static inline int method_is_forwardable(unative_t method)
+ * @param method Method to be decided.
+ *
+ * @return true if the method is forwardable.
+ *
+ */
+static inline bool method_is_forwardable(unative_t method)
 {
 	switch (method) {
@@ -106,7 +109,7 @@
 	case IPC_M_PHONE_HUNGUP:
 		/* This message is meant only for the original recipient. */
-		return 0;
+		return false;
 	default:
-		return 1;
+		return true;
 	}
 }
@@ -116,10 +119,10 @@
  * - some system messages may be forwarded but their content cannot be altered
  *
- * @param method	Method to be decided.
- *
- * @return		Return 1 if the method is immutable on forward.
- *			Otherwise return 0.
- */
-static inline int method_is_immutable(unative_t method)
+ * @param method Method to be decided.
+ *
+ * @return true if the method is immutable on forward.
+ *
+ */
+static inline bool method_is_immutable(unative_t method)
 {
 	switch (method) {
@@ -128,7 +131,7 @@
 	case IPC_M_DATA_WRITE:
 	case IPC_M_DATA_READ:
-		return 1;
+		return true;
 	default:
-		return 0;
+		return false;
 	}
 }
@@ -142,10 +145,10 @@
  * for answer_preprocess().
  *
- * @param call		Call structure to be decided.
- *
- * @return		Return 1 if the old call contents should be saved.
- *			Return 0 otherwise.
- */
-static inline int answer_need_old(call_t *call)
+ * @param call Call structure to be decided.
+ *
+ * @return true if the old call contents should be saved.
+ *
+ */
+static inline bool answer_need_old(call_t *call)
 {
 	switch (IPC_GET_METHOD(call->data)) {
@@ -158,7 +161,7 @@
 	case IPC_M_DATA_WRITE:
 	case IPC_M_DATA_READ:
-		return 1;
+		return true;
 	default:
-		return 0;
+		return false;
 	}
 }
@@ -168,13 +171,12 @@
  * This function is called directly after sys_ipc_answer().
  *
- * @param answer	Call structure with the answer.
- * @param olddata	Saved data of the request.
- *
- * @return		Return 0 on success or an error code. 
+ * @param answer  Call structure with the answer.
+ * @param olddata Saved data of the request.
+ *
+ * @return Return 0 on success or an error code.
+ *
  */
 static inline int answer_preprocess(call_t *answer, ipc_data_t *olddata)
 {
-	int phoneid;
-
 	if ((native_t) IPC_GET_RETVAL(answer->data) == EHANGUP) {
 		/* In case of forward, hangup the forwared phone,
@@ -182,19 +184,20 @@
 		 */
 		mutex_lock(&answer->data.phone->lock);
-		spinlock_lock(&TASK->answerbox.lock);
+		irq_spinlock_lock(&TASK->answerbox.lock, true);
 		if (answer->data.phone->state == IPC_PHONE_CONNECTED) {
 			list_remove(&answer->data.phone->link);
 			answer->data.phone->state = IPC_PHONE_SLAMMED;
 		}
-		spinlock_unlock(&TASK->answerbox.lock);
+		irq_spinlock_unlock(&TASK->answerbox.lock, true);
 		mutex_unlock(&answer->data.phone->lock);
 	}
-
+	
 	if (!olddata)
 		return 0;
-
+	
 	if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTION_CLONE) {
-		phoneid = IPC_GET_ARG1(*olddata);
-		phone_t *phone = &TASK->phones[phoneid]; 
+		int phoneid = IPC_GET_ARG1(*olddata);
+		phone_t *phone = &TASK->phones[phoneid];
+		
 		if (IPC_GET_RETVAL(answer->data) != EOK) {
 			/*
@@ -208,13 +211,14 @@
 			mutex_lock(&phone->lock);
 			if (phone->state == IPC_PHONE_CONNECTED) {
-				spinlock_lock(&phone->callee->lock);
+				irq_spinlock_lock(&phone->callee->lock, true);
 				list_remove(&phone->link);
 				phone->state = IPC_PHONE_SLAMMED;
-				spinlock_unlock(&phone->callee->lock);
+				irq_spinlock_unlock(&phone->callee->lock, true);
 			}
 			mutex_unlock(&phone->lock);
 		}
 	} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME) {
-		phone_t *phone = (phone_t *)IPC_GET_ARG5(*olddata);
+		phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
+		
 		if (IPC_GET_RETVAL(answer->data) != EOK) {
 			/*
@@ -226,13 +230,14 @@
 			mutex_lock(&phone->lock);
 			if (phone->state == IPC_PHONE_CONNECTED) {
-				spinlock_lock(&phone->callee->lock);
+				irq_spinlock_lock(&phone->callee->lock, true);
 				list_remove(&phone->link);
 				phone->state = IPC_PHONE_SLAMMED;
-				spinlock_unlock(&phone->callee->lock);
+				irq_spinlock_unlock(&phone->callee->lock, true);
 			}
 			mutex_unlock(&phone->lock);
 		}
 	} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
-		phoneid = IPC_GET_ARG5(*olddata);
+		int phoneid = IPC_GET_ARG5(*olddata);
+		
 		if (IPC_GET_RETVAL(answer->data) != EOK) {
 			/* The connection was not accepted */
@@ -254,15 +259,10 @@
 		if (!IPC_GET_RETVAL(answer->data)) {
 			/* Accepted, handle as_area receipt */
-			ipl_t ipl;
-			int rc;
-			as_t *as;
 			
-			ipl = interrupts_disable();
-			spinlock_lock(&answer->sender->lock);
-			as = answer->sender->as;
-			spinlock_unlock(&answer->sender->lock);
-			interrupts_restore(ipl);
+			irq_spinlock_lock(&answer->sender->lock, true);
+			as_t *as = answer->sender->as;
+			irq_spinlock_unlock(&answer->sender->lock, true);
 			
-			rc = as_area_share(as, IPC_GET_ARG1(*olddata),
+			int rc = as_area_share(as, IPC_GET_ARG1(*olddata),
 			    IPC_GET_ARG2(*olddata), AS,
 			    IPC_GET_ARG1(answer->data), IPC_GET_ARG3(*olddata));
@@ -272,15 +272,9 @@
 	} else if (IPC_GET_METHOD(*olddata) == IPC_M_SHARE_IN) {
 		if (!IPC_GET_RETVAL(answer->data)) { 
-			ipl_t ipl;
-			as_t *as;
-			int rc;
+			irq_spinlock_lock(&answer->sender->lock, true);
+			as_t *as = answer->sender->as;
+			irq_spinlock_unlock(&answer->sender->lock, true);
 			
-			ipl = interrupts_disable();
-			spinlock_lock(&answer->sender->lock);
-			as = answer->sender->as;
-			spinlock_unlock(&answer->sender->lock);
-			interrupts_restore(ipl);
-			
-			rc = as_area_share(AS, IPC_GET_ARG1(answer->data),
+			int rc = as_area_share(AS, IPC_GET_ARG1(answer->data),
 			    IPC_GET_ARG2(*olddata), as, IPC_GET_ARG1(*olddata),
 			    IPC_GET_ARG2(answer->data));
@@ -301,5 +295,5 @@
 				 */
 				IPC_SET_ARG1(answer->data, dst);
-
+				
 				answer->buffer = malloc(size, 0);
 				int rc = copy_from_uspace(answer->buffer,
@@ -320,15 +314,10 @@
 		if (!IPC_GET_RETVAL(answer->data)) {
 			/* The recipient agreed to receive data. */
-			int rc;
-			uintptr_t dst;
-			size_t size;
-			size_t max_size;
-
-			dst = (uintptr_t)IPC_GET_ARG1(answer->data);
-			size = (size_t)IPC_GET_ARG2(answer->data);
-			max_size = (size_t)IPC_GET_ARG2(*olddata);
-
+			uintptr_t dst = (uintptr_t)IPC_GET_ARG1(answer->data);
+			size_t size = (size_t)IPC_GET_ARG2(answer->data);
+			size_t max_size = (size_t)IPC_GET_ARG2(*olddata);
+			
 			if (size <= max_size) {
-				rc = copy_to_uspace((void *) dst,
+				int rc = copy_to_uspace((void *) dst,
 				    answer->buffer, size);
 				if (rc)
@@ -341,4 +330,5 @@
 		answer->buffer = NULL;
 	}
+	
 	return 0;
 }
@@ -352,7 +342,6 @@
 		mutex_lock(&p2->lock);
 		mutex_lock(&p1->lock);
-	} else {
+	} else
 		mutex_lock(&p1->lock);
-	}
 }
 
@@ -366,24 +355,20 @@
 /** Called before the request is sent.
  *
- * @param call		Call structure with the request.
- * @param phone		Phone that the call will be sent through.
- *
- * @return 		Return 0 on success, ELIMIT or EPERM on error.
+ * @param call  Call structure with the request.
+ * @param phone Phone that the call will be sent through.
+ *
+ * @return Return 0 on success, ELIMIT or EPERM on error.
+ *
  */
 static int request_preprocess(call_t *call, phone_t *phone)
 {
-	int newphid;
-	size_t size;
-	uintptr_t src;
-	int rc;
-
 	switch (IPC_GET_METHOD(call->data)) {
 	case IPC_M_CONNECTION_CLONE: {
 		phone_t *cloned_phone;
-
 		if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
 			return ENOENT;
+		
 		phones_lock(cloned_phone, phone);
-
+		
 		if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
 		    phone->state != IPC_PHONE_CONNECTED) {
@@ -391,4 +376,5 @@
 			return EINVAL;
 		}
+		
 		/*
 		 * We can be pretty sure now that both tasks exist and we are
@@ -396,13 +382,16 @@
 		 * we are effectively preventing them from finishing their
 		 * potential cleanup.
+		 *
 		 */
-		newphid = phone_alloc(phone->callee->task);
+		int newphid = phone_alloc(phone->callee->task);
 		if (newphid < 0) {
 			phones_unlock(cloned_phone, phone);
 			return ELIMIT;
 		}
+		
 		ipc_phone_connect(&phone->callee->task->phones[newphid],
 		    cloned_phone->callee);
 		phones_unlock(cloned_phone, phone);
+		
 		/* Set the new phone for the callee. */
 		IPC_SET_ARG1(call->data, newphid);
@@ -412,8 +401,9 @@
 		IPC_SET_ARG5(call->data, (unative_t) phone);
 		break;
-	case IPC_M_CONNECT_ME_TO:
-		newphid = phone_alloc(TASK);
+	case IPC_M_CONNECT_ME_TO: {
+		int newphid = phone_alloc(TASK);
 		if (newphid < 0)
 			return ELIMIT;
+		
 		/* Set arg5 for server */
 		IPC_SET_ARG5(call->data, (unative_t) &TASK->phones[newphid]);
@@ -421,18 +411,23 @@
 		call->priv = newphid;
 		break;
-	case IPC_M_SHARE_OUT:
-		size = as_area_get_size(IPC_GET_ARG1(call->data));
+	}
+	case IPC_M_SHARE_OUT: {
+		size_t size = as_area_get_size(IPC_GET_ARG1(call->data));
 		if (!size)
 			return EPERM;
+		
 		IPC_SET_ARG2(call->data, size);
 		break;
-	case IPC_M_DATA_READ:
-		size = IPC_GET_ARG2(call->data);
+	}
+	case IPC_M_DATA_READ: {
+		size_t size = IPC_GET_ARG2(call->data);
 		if ((size <= 0 || (size > DATA_XFER_LIMIT)))
 			return ELIMIT;
+		
 		break;
-	case IPC_M_DATA_WRITE:
-		src = IPC_GET_ARG1(call->data);
-		size = IPC_GET_ARG2(call->data);
+	}
+	case IPC_M_DATA_WRITE: {
+		uintptr_t src = IPC_GET_ARG1(call->data);
+		size_t size = IPC_GET_ARG2(call->data);
 		
 		if (size > DATA_XFER_LIMIT)
@@ -440,10 +435,12 @@
 		
 		call->buffer = (uint8_t *) malloc(size, 0);
-		rc = copy_from_uspace(call->buffer, (void *) src, size);
+		int rc = copy_from_uspace(call->buffer, (void *) src, size);
 		if (rc != 0) {
 			free(call->buffer);
 			return rc;
 		}
+		
 		break;
+	}
 #ifdef CONFIG_UDEBUG
 	case IPC_M_DEBUG_ALL:
@@ -453,4 +450,5 @@
 		break;
 	}
+	
 	return 0;
 }
@@ -462,5 +460,6 @@
 /** Do basic kernel processing of received call answer.
  *
- * @param call		Call structure with the answer.
+ * @param call Call structure with the answer.
+ *
  */
 static void process_answer(call_t *call)
@@ -469,5 +468,5 @@
 	    (call->flags & IPC_CALL_FORWARDED))
 		IPC_SET_RETVAL(call->data, EFORWARD);
-
+	
 	if (call->flags & IPC_CALL_CONN_ME_TO) {
 		if (IPC_GET_RETVAL(call->data))
@@ -476,8 +475,11 @@
 			IPC_SET_ARG5(call->data, call->priv);
 	}
-
+	
 	if (call->buffer) {
-		/* This must be an affirmative answer to IPC_M_DATA_READ. */
-		/* or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ... */
+		/*
+		 * This must be an affirmative answer to IPC_M_DATA_READ
+		 * or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ...
+		 *
+		 */
 		uintptr_t dst = IPC_GET_ARG1(call->data);
 		size_t size = IPC_GET_ARG2(call->data);
@@ -492,16 +494,15 @@
 /** Do basic kernel processing of received call request.
  *
- * @param box		Destination answerbox structure.
- * @param call		Call structure with the request.
- *
- * @return 		Return 0 if the call should be passed to userspace.
- *			Return -1 if the call should be ignored.
+ * @param box  Destination answerbox structure.
+ * @param call Call structure with the request.
+ *
+ * @return 0 if the call should be passed to userspace.
+ * @return -1 if the call should be ignored.
+ *
  */
 static int process_request(answerbox_t *box, call_t *call)
 {
-	int phoneid;
-
 	if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) {
-		phoneid = phone_alloc(TASK);
+		int phoneid = phone_alloc(TASK);
 		if (phoneid < 0) { /* Failed to allocate phone */
 			IPC_SET_RETVAL(call->data, ELIMIT);
@@ -509,6 +510,8 @@
 			return -1;
 		}
+		
 		IPC_SET_ARG5(call->data, phoneid);
 	}
+	
 	switch (IPC_GET_METHOD(call->data)) {
 	case IPC_M_DEBUG_ALL:
@@ -517,4 +520,5 @@
 		break;
 	}
+	
 	return 0;
 }
@@ -525,31 +529,29 @@
  * the generic function (i.e. sys_ipc_call_sync_slow()).
  *
- * @param phoneid	Phone handle for the call.
- * @param method	Method of the call.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param data		Address of userspace structure where the reply call will
- *			be stored.
- *
- * @return		Returns 0 on success.
- *			Return ENOENT if there is no such phone handle.
+ * @param phoneid Phone handle for the call.
+ * @param method  Method of the call.
+ * @param arg1    Service-defined payload argument.
+ * @param arg2    Service-defined payload argument.
+ * @param arg3    Service-defined payload argument.
+ * @param data    Address of userspace structure where the reply call will
+ *                be stored.
+ *
+ * @return 0 on success.
+ * @return ENOENT if there is no such phone handle.
+ *
  */
 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
     unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data)
 {
-	call_t *call;
 	phone_t *phone;
-	int res;
-	int rc;
-
 	if (phone_get(phoneid, &phone) != EOK)
 		return ENOENT;
 
-	call = ipc_call_alloc(0);
+	call_t *call = ipc_call_alloc(0);
 	IPC_SET_METHOD(call->data, method);
 	IPC_SET_ARG1(call->data, arg1);
 	IPC_SET_ARG2(call->data, arg2);
 	IPC_SET_ARG3(call->data, arg3);
+	
 	/*
 	 * To achieve deterministic behavior, zero out arguments that are beyond
@@ -558,6 +560,9 @@
 	IPC_SET_ARG4(call->data, 0);
 	IPC_SET_ARG5(call->data, 0);
-
-	if (!(res = request_preprocess(call, phone))) {
+	
+	int res = request_preprocess(call, phone);
+	int rc;
+	
+	if (!res) {
 #ifdef CONFIG_UDEBUG
 		udebug_stoppable_begin();
@@ -567,18 +572,20 @@
 		udebug_stoppable_end();
 #endif
+		
 		if (rc != EOK) {
 			/* The call will be freed by ipc_cleanup(). */
 			return rc;
 		}
+		
 		process_answer(call);
-
-	} else {
+		
+	} else
 		IPC_SET_RETVAL(call->data, res);
-	}
+	
 	rc = STRUCT_TO_USPACE(&data->args, &call->data.args);
 	ipc_call_free(call);
 	if (rc != 0)
 		return rc;
-
+	
 	return 0;
 }
@@ -586,24 +593,21 @@
 /** Make a synchronous IPC call allowing to transmit the entire payload.
  *
- * @param phoneid	Phone handle for the call.
- * @param question	Userspace address of call data with the request.
- * @param reply		Userspace address of call data where to store the
- *			answer.
- *
- * @return		Zero on success or an error code.
+ * @param phoneid  Phone handle for the call.
+ * @param question Userspace address of call data with the request.
+ * @param reply    Userspace address of call data where to store the
+ *                 answer.
+ *
+ * @return Zero on success or an error code.
+ *
  */
 unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
     ipc_data_t *reply)
 {
-	call_t *call;
 	phone_t *phone;
-	int res;
-	int rc;
-
 	if (phone_get(phoneid, &phone) != EOK)
 		return ENOENT;
 
-	call = ipc_call_alloc(0);
-	rc = copy_from_uspace(&call->data.args, &question->args,
+	call_t *call = ipc_call_alloc(0);
+	int rc = copy_from_uspace(&call->data.args, &question->args,
 	    sizeof(call->data.args));
 	if (rc != 0) {
@@ -611,7 +615,8 @@
 		return (unative_t) rc;
 	}
-
-
-	if (!(res = request_preprocess(call, phone))) {
+	
+	int res = request_preprocess(call, phone);
+	
+	if (!res) {
 #ifdef CONFIG_UDEBUG
 		udebug_stoppable_begin();
@@ -621,17 +626,19 @@
 		udebug_stoppable_end();
 #endif
+		
 		if (rc != EOK) {
 			/* The call will be freed by ipc_cleanup(). */
 			return rc;
 		}
+		
 		process_answer(call);
-	} else 
+	} else
 		IPC_SET_RETVAL(call->data, res);
-
+	
 	rc = STRUCT_TO_USPACE(&reply->args, &call->data.args);
 	ipc_call_free(call);
 	if (rc != 0)
 		return rc;
-
+	
 	return 0;
 }
@@ -639,5 +646,6 @@
 /** Check that the task did not exceed the allowed limit of asynchronous calls.
  *
- * @return 		Return 0 if limit not reached or -1 if limit exceeded.
+ * @return 0 if limit not reached or -1 if limit exceeded.
+ *
  */
 static int check_call_limit(void)
@@ -647,4 +655,5 @@
 		return -1;
 	}
+	
 	return 0;
 }
@@ -655,30 +664,28 @@
  * the generic function sys_ipc_call_async_slow().
  *
- * @param phoneid	Phone handle for the call.
- * @param method	Method of the call.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param arg4		Service-defined payload argument.
- *
- * @return 		Return call hash on success.
- *			Return IPC_CALLRET_FATAL in case of a fatal error and 
- *			IPC_CALLRET_TEMPORARY if there are too many pending
- *			asynchronous requests; answers should be handled first.
+ * @param phoneid Phone handle for the call.
+ * @param method  Method of the call.
+ * @param arg1    Service-defined payload argument.
+ * @param arg2    Service-defined payload argument.
+ * @param arg3    Service-defined payload argument.
+ * @param arg4    Service-defined payload argument.
+ *
+ * @return Call hash on success.
+ * @return IPC_CALLRET_FATAL in case of a fatal error.
+ * @return IPC_CALLRET_TEMPORARY if there are too many pending
+ *         asynchronous requests; answers should be handled first.
+ *
  */
 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
     unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)
 {
-	call_t *call;
-	phone_t *phone;
-	int res;
-
 	if (check_call_limit())
 		return IPC_CALLRET_TEMPORARY;
-
+	
+	phone_t *phone;
 	if (phone_get(phoneid, &phone) != EOK)
 		return IPC_CALLRET_FATAL;
-
-	call = ipc_call_alloc(0);
+	
+	call_t *call = ipc_call_alloc(0);
 	IPC_SET_METHOD(call->data, method);
 	IPC_SET_ARG1(call->data, arg1);
@@ -686,4 +693,5 @@
 	IPC_SET_ARG3(call->data, arg3);
 	IPC_SET_ARG4(call->data, arg4);
+	
 	/*
 	 * To achieve deterministic behavior, zero out arguments that are beyond
@@ -691,10 +699,12 @@
 	 */
 	IPC_SET_ARG5(call->data, 0);
-
-	if (!(res = request_preprocess(call, phone)))
+	
+	int res = request_preprocess(call, phone);
+	
+	if (!res)
 		ipc_call(phone, call);
 	else
 		ipc_backsend_err(phone, call, res);
-
+	
 	return (unative_t) call;
 }
@@ -702,24 +712,21 @@
 /** Make an asynchronous IPC call allowing to transmit the entire payload.
  *
- * @param phoneid	Phone handle for the call.
- * @param data		Userspace address of call data with the request.
- *
- * @return		See sys_ipc_call_async_fast(). 
+ * @param phoneid Phone handle for the call.
+ * @param data    Userspace address of call data with the request.
+ *
+ * @return See sys_ipc_call_async_fast().
+ *
  */
 unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data)
 {
-	call_t *call;
-	phone_t *phone;
-	int res;
-	int rc;
-
 	if (check_call_limit())
 		return IPC_CALLRET_TEMPORARY;
-
+	
+	phone_t *phone;
 	if (phone_get(phoneid, &phone) != EOK)
 		return IPC_CALLRET_FATAL;
 
-	call = ipc_call_alloc(0);
-	rc = copy_from_uspace(&call->data.args, &data->args,
+	call_t *call = ipc_call_alloc(0);
+	int rc = copy_from_uspace(&call->data.args, &data->args,
 	    sizeof(call->data.args));
 	if (rc != 0) {
@@ -727,45 +734,48 @@
 		return (unative_t) rc;
 	}
-	if (!(res = request_preprocess(call, phone)))
+	
+	int res = request_preprocess(call, phone);
+	
+	if (!res)
 		ipc_call(phone, call);
 	else
 		ipc_backsend_err(phone, call, res);
-
+	
 	return (unative_t) call;
 }
 
-/** Forward a received call to another destination - common code for both the
- * fast and the slow version.
- *
- * @param callid	Hash of the call to forward.
- * @param phoneid	Phone handle to use for forwarding.
- * @param method	New method to use for the forwarded call.
- * @param arg1		New value of the first argument for the forwarded call.
- * @param arg2		New value of the second argument for the forwarded call.
- * @param arg3		New value of the third argument for the forwarded call.
- * @param arg4		New value of the fourth argument for the forwarded call.
- * @param arg5		New value of the fifth argument for the forwarded call.
- * @param mode		Flags that specify mode of the forward operation.
- * @param slow		If true, arg3, arg4 and arg5 are considered. Otherwise
- *			the function considers only the fast version arguments:
- *			i.e. arg1 and arg2.
- *
- * @return		Return 0 on succes, otherwise return an error code.
- *
- * Warning:	Make sure that ARG5 is not rewritten for certain system IPC
+/** Forward a received call to another destination
+ *
+ * Common code for both the fast and the slow version.
+ *
+ * @param callid  Hash of the call to forward.
+ * @param phoneid Phone handle to use for forwarding.
+ * @param method  New method to use for the forwarded call.
+ * @param arg1    New value of the first argument for the forwarded call.
+ * @param arg2    New value of the second argument for the forwarded call.
+ * @param arg3    New value of the third argument for the forwarded call.
+ * @param arg4    New value of the fourth argument for the forwarded call.
+ * @param arg5    New value of the fifth argument for the forwarded call.
+ * @param mode    Flags that specify mode of the forward operation.
+ * @param slow    If true, arg3, arg4 and arg5 are considered. Otherwise
+ *                the function considers only the fast version arguments:
+ *                i.e. arg1 and arg2.
+ *
+ * @return 0 on succes, otherwise an error code.
+ *
+ * Warning: Make sure that ARG5 is not rewritten for certain system IPC
+ *
  */
 static unative_t sys_ipc_forward_common(unative_t callid, unative_t phoneid,
     unative_t method, unative_t arg1, unative_t arg2, unative_t arg3,
-    unative_t arg4, unative_t arg5, int mode, bool slow)
-{
-	call_t *call;
-	phone_t *phone;
-
-	call = get_call(callid);
+    unative_t arg4, unative_t arg5, unsigned int mode, bool slow)
+{
+	call_t *call = get_call(callid);
 	if (!call)
 		return ENOENT;
 	
 	call->flags |= IPC_CALL_FORWARDED;
-
+	
+	phone_t *phone;
 	if (phone_get(phoneid, &phone) != EOK) {
 		IPC_SET_RETVAL(call->data, EFORWARD);
@@ -773,5 +783,5 @@
 		return ENOENT;
 	}
-
+	
 	if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
 		IPC_SET_RETVAL(call->data, EFORWARD);
@@ -779,5 +789,5 @@
 		return EPERM;
 	}
-
+	
 	/*
 	 * Userspace is not allowed to change method of system methods on
@@ -790,8 +800,9 @@
 			if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
 				phone_dealloc(IPC_GET_ARG5(call->data));
-
+			
 			IPC_SET_ARG1(call->data, method);
 			IPC_SET_ARG2(call->data, arg1);
 			IPC_SET_ARG3(call->data, arg2);
+			
 			if (slow) {
 				IPC_SET_ARG4(call->data, arg3);
@@ -812,18 +823,9 @@
 		}
 	}
-
+	
 	return ipc_forward(call, phone, &TASK->answerbox, mode);
 }
 
 /** Forward a received call to another destination - fast version.
- *
- * @param callid	Hash of the call to forward.
- * @param phoneid	Phone handle to use for forwarding.
- * @param method	New method to use for the forwarded call.
- * @param arg1		New value of the first argument for the forwarded call.
- * @param arg2		New value of the second argument for the forwarded call.
- * @param mode		Flags that specify mode of the forward operation.
- *
- * @return		Return 0 on succes, otherwise return an error code.
  *
  * In case the original method is a system method, ARG1, ARG2 and ARG3 are
@@ -833,7 +835,17 @@
  * is a set of immutable methods, for which the new method and arguments are not
  * set and these values are ignored.
+ *
+ * @param callid  Hash of the call to forward.
+ * @param phoneid Phone handle to use for forwarding.
+ * @param method  New method to use for the forwarded call.
+ * @param arg1    New value of the first argument for the forwarded call.
+ * @param arg2    New value of the second argument for the forwarded call.
+ * @param mode    Flags that specify mode of the forward operation.
+ *
+ * @return 0 on succes, otherwise an error code.
+ *
  */
 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
-    unative_t method, unative_t arg1, unative_t arg2, int mode)
+    unative_t method, unative_t arg1, unative_t arg2, unsigned int mode)
 {
 	return sys_ipc_forward_common(callid, phoneid, method, arg1, arg2, 0, 0,
@@ -842,11 +854,4 @@
 
 /** Forward a received call to another destination - slow version.
- *
- * @param callid	Hash of the call to forward.
- * @param phoneid	Phone handle to use for forwarding.
- * @param data		Userspace address of the new IPC data. 
- * @param mode		Flags that specify mode of the forward operation.
- *
- * @return		Return 0 on succes, otherwise return an error code.
  *
  * This function is the slow verision of the sys_ipc_forward_fast interface.
@@ -856,16 +861,22 @@
  * methods, it additionally stores the new value of arg3, arg4 and arg5,
  * respectively, to ARG3, ARG4 and ARG5, respectively.
+ *
+ * @param callid  Hash of the call to forward.
+ * @param phoneid Phone handle to use for forwarding.
+ * @param data    Userspace address of the new IPC data.
+ * @param mode    Flags that specify mode of the forward operation.
+ *
+ * @return 0 on succes, otherwise an error code.
+ *
  */
 unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
-    ipc_data_t *data, int mode)
+    ipc_data_t *data, unsigned int mode)
 {
 	ipc_data_t newdata;
-	int rc;
-
-	rc = copy_from_uspace(&newdata.args, &data->args,
+	int rc = copy_from_uspace(&newdata.args, &data->args,
 	    sizeof(newdata.args));
-	if (rc != 0) 
+	if (rc != 0)
 		return (unative_t) rc;
-
+	
 	return sys_ipc_forward_common(callid, phoneid,
 	    IPC_GET_METHOD(newdata), IPC_GET_ARG1(newdata),
@@ -879,34 +890,34 @@
  * than the generic sys_ipc_answer().
  *
- * @param callid	Hash of the call to be answered.
- * @param retval	Return value of the answer.
- * @param arg1		Service-defined return value.
- * @param arg2		Service-defined return value.
- * @param arg3		Service-defined return value.
- * @param arg4		Service-defined return value.
- *
- * @return		Return 0 on success, otherwise return an error code.	
+ * @param callid Hash of the call to be answered.
+ * @param retval Return value of the answer.
+ * @param arg1   Service-defined return value.
+ * @param arg2   Service-defined return value.
+ * @param arg3   Service-defined return value.
+ * @param arg4   Service-defined return value.
+ *
+ * @return 0 on success, otherwise an error code.
+ *
  */
 unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
     unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)
 {
-	call_t *call;
-	ipc_data_t saved_data;
-	int saveddata = 0;
-	int rc;
-
 	/* Do not answer notification callids */
 	if (callid & IPC_CALLID_NOTIFICATION)
 		return 0;
-
-	call = get_call(callid);
+	
+	call_t *call = get_call(callid);
 	if (!call)
 		return ENOENT;
-
+	
+	ipc_data_t saved_data;
+	bool saved;
+	
 	if (answer_need_old(call)) {
 		memcpy(&saved_data, &call->data, sizeof(call->data));
-		saveddata = 1;
-	}
-
+		saved = true;
+	} else
+		saved = false;
+	
 	IPC_SET_RETVAL(call->data, retval);
 	IPC_SET_ARG1(call->data, arg1);
@@ -914,4 +925,5 @@
 	IPC_SET_ARG3(call->data, arg3);
 	IPC_SET_ARG4(call->data, arg4);
+	
 	/*
 	 * To achieve deterministic behavior, zero out arguments that are beyond
@@ -919,6 +931,6 @@
 	 */
 	IPC_SET_ARG5(call->data, 0);
-	rc = answer_preprocess(call, saveddata ? &saved_data : NULL);
-
+	int rc = answer_preprocess(call, saved ? &saved_data : NULL);
+	
 	ipc_answer(&TASK->answerbox, call);
 	return rc;
@@ -927,37 +939,37 @@
 /** Answer an IPC call.
  *
- * @param callid	Hash of the call to be answered.
- * @param data		Userspace address of call data with the answer.
- *
- * @return		Return 0 on success, otherwise return an error code.
+ * @param callid Hash of the call to be answered.
+ * @param data   Userspace address of call data with the answer.
+ *
+ * @return 0 on success, otherwise an error code.
+ *
  */
 unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data)
 {
-	call_t *call;
-	ipc_data_t saved_data;
-	int saveddata = 0;
-	int rc;
-
 	/* Do not answer notification callids */
 	if (callid & IPC_CALLID_NOTIFICATION)
 		return 0;
-
-	call = get_call(callid);
+	
+	call_t *call = get_call(callid);
 	if (!call)
 		return ENOENT;
-
+	
+	ipc_data_t saved_data;
+	bool saved;
+	
 	if (answer_need_old(call)) {
 		memcpy(&saved_data, &call->data, sizeof(call->data));
-		saveddata = 1;
-	}
-	rc = copy_from_uspace(&call->data.args, &data->args, 
+		saved = true;
+	} else
+		saved = false;
+	
+	int rc = copy_from_uspace(&call->data.args, &data->args, 
 	    sizeof(call->data.args));
 	if (rc != 0)
 		return rc;
-
-	rc = answer_preprocess(call, saveddata ? &saved_data : NULL);
+	
+	rc = answer_preprocess(call, saved ? &saved_data : NULL);
 	
 	ipc_answer(&TASK->answerbox, call);
-
 	return rc;
 }
@@ -965,18 +977,19 @@
 /** Hang up a phone.
  *
- * @param		Phone handle of the phone to be hung up.
- *
- * @return		Return 0 on success or an error code.
+ * @param Phone handle of the phone to be hung up.
+ *
+ * @return 0 on success or an error code.
+ *
  */
 unative_t sys_ipc_hangup(unative_t phoneid)
 {
 	phone_t *phone;
-
+	
 	if (phone_get(phoneid, &phone) != EOK)
 		return ENOENT;
-
+	
 	if (ipc_phone_hangup(phone))
 		return -1;
-
+	
 	return 0;
 }
@@ -984,32 +997,36 @@
 /** Wait for an incoming IPC call or an answer.
  *
- * @param calldata	Pointer to buffer where the call/answer data is stored.
- * @param usec 		Timeout. See waitq_sleep_timeout() for explanation.
- * @param flags		Select mode of sleep operation. See waitq_sleep_timeout()
- *			for explanation.
- *
- * @return 		Hash of the call.
- *			If IPC_CALLID_NOTIFICATION bit is set in the hash, the
- *			call is a notification. IPC_CALLID_ANSWERED denotes an
- *			answer.
- */
-unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, int flags)
+ * @param calldata Pointer to buffer where the call/answer data is stored.
+ * @param usec     Timeout. See waitq_sleep_timeout() for explanation.
+ * @param flags    Select mode of sleep operation. See waitq_sleep_timeout()
+ *                 for explanation.
+ *
+ * @return Hash of the call.
+ *         If IPC_CALLID_NOTIFICATION bit is set in the hash, the
+ *         call is a notification. IPC_CALLID_ANSWERED denotes an
+ *         answer.
+ *
+ */
+unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
+    unsigned int flags)
 {
 	call_t *call;
-
+	
 restart:
-
+	
 #ifdef CONFIG_UDEBUG
 	udebug_stoppable_begin();
-#endif	
+#endif
+	
 	call = ipc_wait_for_call(&TASK->answerbox, usec,
 	    flags | SYNCH_FLAGS_INTERRUPTIBLE);
-
+	
 #ifdef CONFIG_UDEBUG
 	udebug_stoppable_end();
 #endif
+	
 	if (!call)
 		return 0;
-
+	
 	if (call->flags & IPC_CALL_NOTIF) {
 		/* Set in_phone_hash to the interrupt counter */
@@ -1017,13 +1034,13 @@
 		
 		STRUCT_TO_USPACE(calldata, &call->data);
-
+		
 		ipc_call_free(call);
 		
 		return ((unative_t) call) | IPC_CALLID_NOTIFICATION;
 	}
-
+	
 	if (call->flags & IPC_CALL_ANSWERED) {
 		process_answer(call);
-
+		
 		if (call->flags & IPC_CALL_DISCARD_ANSWER) {
 			ipc_call_free(call);
@@ -1037,14 +1054,14 @@
 			atomic_dec(&TASK->active_calls);
 		}
-
+		
 		STRUCT_TO_USPACE(&calldata->args, &call->data.args);
 		ipc_call_free(call);
-
+		
 		return ((unative_t) call) | IPC_CALLID_ANSWERED;
 	}
-
+	
 	if (process_request(&TASK->answerbox, call))
 		goto restart;
-
+	
 	/* Include phone address('id') of the caller in the request,
 	 * copy whole call->data, not only call->data.args */
@@ -1055,23 +1072,27 @@
 		 */
 		ipc_data_t saved_data;
-		int saveddata = 0;
-
+		bool saved;
+		
 		if (answer_need_old(call)) {
 			memcpy(&saved_data, &call->data, sizeof(call->data));
-			saveddata = 1;
-		}
+			saved = true;
+		} else
+			saved = false;
 		
 		IPC_SET_RETVAL(call->data, EPARTY);
-		(void) answer_preprocess(call, saveddata ? &saved_data : NULL);
+		(void) answer_preprocess(call, saved ? &saved_data : NULL);
 		ipc_answer(&TASK->answerbox, call);
 		return 0;
 	}
-	return (unative_t)call;
-}
-
-/** Interrupt one thread from sys_ipc_wait_for_call(). */
+	
+	return (unative_t) call;
+}
+
+/** Interrupt one thread from sys_ipc_wait_for_call().
+ *
+ */
 unative_t sys_ipc_poke(void)
 {
-	waitq_unsleep(&TASK->answerbox.wq);	
+	waitq_unsleep(&TASK->answerbox.wq);
 	return EOK;
 }
@@ -1079,10 +1100,11 @@
 /** Connect an IRQ handler to a task.
  *
- * @param inr		IRQ number.
- * @param devno		Device number.
- * @param method	Method to be associated with the notification.
- * @param ucode		Uspace pointer to the top-half pseudocode.
- *
- * @return		EPERM or a return code returned by ipc_irq_register().
+ * @param inr    IRQ number.
+ * @param devno  Device number.
+ * @param method Method to be associated with the notification.
+ * @param ucode  Uspace pointer to the top-half pseudocode.
+ *
+ * @return EPERM or a return code returned by ipc_irq_register().
+ *
  */
 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
@@ -1091,5 +1113,5 @@
 	if (!(cap_get(TASK) & CAP_IRQ_REG))
 		return EPERM;
-
+	
 	return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);
 }
@@ -1097,8 +1119,9 @@
 /** Disconnect an IRQ handler from a task.
  *
- * @param inr		IRQ number.
- * @param devno		Device number.
- *
- * @return		Zero on success or EPERM on error..
+ * @param inr   IRQ number.
+ * @param devno Device number.
+ *
+ * @return Zero on success or EPERM on error.
+ *
  */
 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)
@@ -1106,7 +1129,7 @@
 	if (!(cap_get(TASK) & CAP_IRQ_REG))
 		return EPERM;
-
+	
 	ipc_irq_unregister(&TASK->answerbox, inr, devno);
-
+	
 	return 0;
 }
@@ -1114,8 +1137,8 @@
 #include <console/console.h>
 
-/**
- * Syscall connect to a task by id.
- *
- * @return 		Phone id on success, or negative error code.
+/** Syscall connect to a task by id.
+ *
+ * @return Phone id on success, or negative error code.
+ *
  */
 unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)
@@ -1123,12 +1146,10 @@
 #ifdef CONFIG_UDEBUG
 	sysarg64_t taskid_arg;
-	int rc;
-	
-	rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
+	int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
 	if (rc != 0)
 		return (unative_t) rc;
-
+	
 	LOG("sys_ipc_connect_kbox(%" PRIu64 ")\n", taskid_arg.value);
-
+	
 	return ipc_connect_kbox(taskid_arg.value);
 #else
