Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision 9ef1b79b3edc59d798cf9373b2025212317686c1)
+++ kernel/generic/include/ipc/ipc.h	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -179,5 +179,5 @@
 extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t);
 extern void ipc_answerbox_slam_phones(answerbox_t *, bool);
-extern void ipc_cleanup_call_list(list_t *);
+extern void ipc_cleanup_call_list(answerbox_t *, list_t *);
 
 extern void ipc_print_task(task_id_t);
Index: kernel/generic/include/ipc/sysipc_priv.h
===================================================================
--- kernel/generic/include/ipc/sysipc_priv.h	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
+++ kernel/generic/include/ipc/sysipc_priv.h	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Jakub Jermar 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup genericipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_SYSIPC_PRIV_H_
+#define KERN_SYSIPC_PRIV_H_
+
+#include <ipc/ipc.h>
+
+extern int answer_preprocess(call_t *, ipc_data_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 9ef1b79b3edc59d798cf9373b2025212317686c1)
+++ kernel/generic/src/ipc/ipc.c	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -46,4 +46,5 @@
 #include <ipc/event.h>
 #include <ipc/sysipc_ops.h>
+#include <ipc/sysipc_priv.h>
 #include <errno.h>
 #include <mm/slab.h>
@@ -475,9 +476,10 @@
 /** Answer all calls from list with EHANGUP answer.
  *
+ * @param box Answerbox with the list.
  * @param lst Head of the list to be cleaned up.
- *
- */
-void ipc_cleanup_call_list(list_t *lst)
-{
+ */
+void ipc_cleanup_call_list(answerbox_t *box, list_t *lst)
+{
+	irq_spinlock_lock(&box->lock, true);
 	while (!list_empty(lst)) {
 		call_t *call = list_get_instance(list_first(lst), call_t,
@@ -485,8 +487,15 @@
 		
 		list_remove(&call->ab_link);
-		
+
+		irq_spinlock_unlock(&box->lock, true);
+
+		ipc_data_t old = call->data;
 		IPC_SET_RETVAL(call->data, EHANGUP);
+		answer_preprocess(call, &old);
 		_ipc_answer_free_call(call, true);
-	}
+
+		irq_spinlock_lock(&box->lock, true);
+	}
+	irq_spinlock_unlock(&box->lock, true);
 }
 
@@ -694,8 +703,7 @@
 	
 	/* Answer all messages in 'calls' and 'dispatched_calls' queues */
-	irq_spinlock_lock(&TASK->answerbox.lock, true);
-	ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
-	ipc_cleanup_call_list(&TASK->answerbox.calls);
-	irq_spinlock_unlock(&TASK->answerbox.lock, true);
+	ipc_cleanup_call_list(&TASK->answerbox,
+	    &TASK->answerbox.dispatched_calls);
+	ipc_cleanup_call_list(&TASK->answerbox, &TASK->answerbox.calls);
 
 	ipc_forget_all_active_calls();
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 9ef1b79b3edc59d798cf9373b2025212317686c1)
+++ kernel/generic/src/ipc/kbox.c	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -88,8 +88,6 @@
 	
 	/* Answer all messages in 'calls' and 'dispatched_calls' queues. */
-	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);
-	irq_spinlock_unlock(&TASK->kb.box.lock, true);
+	ipc_cleanup_call_list(&TASK->kb.box, &TASK->kb.box.dispatched_calls);
+	ipc_cleanup_call_list(&TASK->kb.box, &TASK->kb.box.calls);
 }
 
Index: kernel/generic/src/ipc/ops/concttome.c
===================================================================
--- kernel/generic/src/ipc/ops/concttome.c	(revision 9ef1b79b3edc59d798cf9373b2025212317686c1)
+++ kernel/generic/src/ipc/ops/concttome.c	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -40,19 +40,15 @@
 #include <arch.h>
 
+static int request_preprocess(call_t *call, phone_t *phone)
+{
+	/* Start with the assumption that there is no allocated phoneid. */
+	IPC_SET_ARG5(call->data, -1);
+	return EOK;
+}
+
 static int request_process(call_t *call, answerbox_t *box)
 {
 	int phoneid = phone_alloc(TASK);
 
-	if (phoneid < 0) {
-		IPC_SET_RETVAL(call->data, ELIMIT);
-		/*
-		 * This is a shortcut which bypasses the standard call
-		 * processing hooks. We are still playing it save here as
-		 * there is no state to be cleaned up at this stage.
-		 */
-		ipc_answer(box, call);
-		return -1;
-	}
-		
 	IPC_SET_ARG5(call->data, phoneid);
 	
@@ -64,5 +60,6 @@
 	int phoneid = (int) IPC_GET_ARG5(*olddata);
 
-	phone_dealloc(phoneid);
+	if (phoneid >= 0)
+		phone_dealloc(phoneid);
 }
 
@@ -74,9 +71,11 @@
 		/* The connection was not accepted */
 		answer_cleanup(answer, olddata);
-	} else {
+	} else if (phoneid >= 0) {
 		/* The connection was accepted */
 		phone_connect(phoneid, &answer->sender->answerbox);
 		/* Set 'phone hash' as arg5 of response */
 		IPC_SET_ARG5(answer->data, (sysarg_t) &TASK->phones[phoneid]);
+	} else {
+		IPC_SET_RETVAL(answer->data, ELIMIT);
 	}
 
@@ -86,5 +85,5 @@
 
 sysipc_ops_t ipc_m_connect_to_me_ops = {
-	.request_preprocess = null_request_preprocess,
+	.request_preprocess = request_preprocess,
 	.request_forget = null_request_forget,
 	.request_process = request_process,
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision 9ef1b79b3edc59d798cf9373b2025212317686c1)
+++ kernel/generic/src/ipc/sysipc.c	(revision 5d3ed34dfe2da2410c8b3b125cd918dfcef7a6a5)
@@ -40,4 +40,5 @@
 #include <ipc/sysipc.h>
 #include <ipc/sysipc_ops.h>
+#include <ipc/sysipc_priv.h>
 #include <ipc/irq.h>
 #include <ipc/ipcrsc.h>
@@ -157,5 +158,5 @@
  *
  */
-static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
+int answer_preprocess(call_t *answer, ipc_data_t *olddata)
 {
 	int rc = EOK;
