Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision 4874c2dc3da3748951cb71f24805c35b88106d0f)
+++ kernel/generic/include/ipc/ipc.h	(revision b14e35f21d106227a205a0ef257dff8643000ec4)
@@ -175,12 +175,13 @@
 	waitq_t wq;
 
-	link_t connected_phones; /**< Phones connected to this answerbox */
-	link_t calls;            /**< Received calls */
-	link_t dispatched_calls; /* Should be hash table in the future */
-
-	link_t answers;          /**< Answered calls */
+	link_t connected_phones;	/**< Phones connected to this answerbox */
+	link_t calls;			/**< Received calls */
+	link_t dispatched_calls;	/* Should be hash table in the future */
+
+	link_t answers;			/**< Answered calls */
 
 	SPINLOCK_DECLARE(irq_lock);
-	link_t irq_notifs;       /**< Notifications from IRQ handlers */
+	link_t irq_notifs;       	/**< Notifications from IRQ handlers */
+	link_t irq_head;		/**< IRQs with notifications to this answerbox. */
 };
 
Index: kernel/generic/include/ipc/irq.h
===================================================================
--- kernel/generic/include/ipc/irq.h	(revision 4874c2dc3da3748951cb71f24805c35b88106d0f)
+++ kernel/generic/include/ipc/irq.h	(revision b14e35f21d106227a205a0ef257dff8643000ec4)
@@ -72,4 +72,5 @@
 #include <typedefs.h>
 #include <arch/types.h>
+#include <adt/list.h>
 
 /** IPC notification config structure.
@@ -84,4 +85,7 @@
 	irq_code_t *code;		/**< Top-half pseudocode. */
 	count_t counter;		/**< Counter. */
+	link_t link;			/**< Link between IRQs that are notifying the
+					     same answerbox. The list is protected by
+					     the answerbox irq_lock. */
 };
 
Index: kernel/generic/src/ddi/irq.c
===================================================================
--- kernel/generic/src/ddi/irq.c	(revision 4874c2dc3da3748951cb71f24805c35b88106d0f)
+++ kernel/generic/src/ddi/irq.c	(revision b14e35f21d106227a205a0ef257dff8643000ec4)
@@ -146,8 +146,10 @@
 	irq->handler = NULL;
 	irq->arg = NULL;
+	irq->notif_cfg.notify = false;
 	irq->notif_cfg.answerbox = NULL;
 	irq->notif_cfg.code = NULL;
 	irq->notif_cfg.method = 0;
 	irq->notif_cfg.counter = 0;
+	link_initialize(&irq->notif_cfg.link);
 }
 
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 4874c2dc3da3748951cb71f24805c35b88106d0f)
+++ kernel/generic/src/ipc/ipc.c	(revision b14e35f21d106227a205a0ef257dff8643000ec4)
@@ -109,4 +109,5 @@
 	list_initialize(&box->answers);
 	list_initialize(&box->irq_notifs);
+	list_initialize(&box->irq_head);
 	box->task = TASK;
 }
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 4874c2dc3da3748951cb71f24805c35b88106d0f)
+++ kernel/generic/src/ipc/irq.c	(revision b14e35f21d106227a205a0ef257dff8643000ec4)
@@ -177,4 +177,5 @@
 	if (irq) {
 		if (irq->notif_cfg.answerbox == box) {
+			code_free(irq->notif_cfg.code);
 			irq->notif_cfg.notify = false;
 			irq->notif_cfg.answerbox = NULL;
@@ -182,5 +183,9 @@
 			irq->notif_cfg.method = 0;
 			irq->notif_cfg.counter = 0;
-			code_free(irq->notif_cfg.code);
+
+			spinlock_lock(&box->irq_lock);
+			list_remove(&irq->notif_cfg.link);
+			spinlock_unlock(&box->irq_lock);
+			
 			spinlock_unlock(&irq->lock);
 		}
@@ -199,6 +204,5 @@
  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
  */
-int
-ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method, irq_code_t *ucode)
+int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method, irq_code_t *ucode)
 {
 	ipl_t ipl;
@@ -233,4 +237,9 @@
 	irq->notif_cfg.code = code;
 	irq->notif_cfg.counter = 0;
+
+	spinlock_lock(&box->irq_lock);
+	list_append(&irq->notif_cfg.link, &box->irq_head);
+	spinlock_unlock(&box->irq_lock);
+
 	spinlock_unlock(&irq->lock);
 	interrupts_restore(ipl);
@@ -311,9 +320,52 @@
 /** Disconnect all IRQ notifications from an answerbox.
  *
+ * This function is effective because the answerbox contains
+ * list of all irq_t structures that are registered to
+ * send notifications to it.
+ *
  * @param box Answerbox for which we want to carry out the cleanup.
  */
 void ipc_irq_cleanup(answerbox_t *box)
 {
-	/* TODO */
+	ipl_t ipl;
+	
+loop:
+	ipl = interrupts_disable();
+	spinlock_lock(&box->irq_lock);
+	
+	while (box->irq_head.next != &box->irq_head) {
+		link_t *cur = box->irq_head.next;
+		irq_t *irq;
+		
+		irq = list_get_instance(cur, irq_t, notif_cfg.link);
+		if (!spinlock_trylock(&irq->lock)) {
+			/*
+			 * Avoid deadlock by trying again.
+			 */
+			spinlock_unlock(&box->irq_lock);
+			interrupts_restore(ipl);
+			goto loop;
+		}
+		
+		ASSERT(irq->notif_cfg.answerbox == box);
+		
+		list_remove(&irq->notif_cfg.link);
+		
+		/*
+		 * Don't forget to free any top-half pseudocode.
+		 */
+		code_free(irq->notif_cfg.code);
+		
+		irq->notif_cfg.notify = false;
+		irq->notif_cfg.answerbox = NULL;
+		irq->notif_cfg.code = NULL;
+		irq->notif_cfg.method = 0;
+		irq->notif_cfg.counter = 0;
+
+		spinlock_unlock(&irq->lock);
+	}
+	
+	spinlock_unlock(&box->irq_lock);
+	interrupts_restore(ipl);
 }
 
