Index: kernel/generic/include/ipc/kbox.h
===================================================================
--- kernel/generic/include/ipc/kbox.h	(revision 0aa1665b932e64c1786b7cc2ee1964f9694cfd8b)
+++ kernel/generic/include/ipc/kbox.h	(revision 31696b4fbd84b5c8090a758e9a35ba49a9156b52)
@@ -38,4 +38,16 @@
 #include <typedefs.h>
 
+/** Kernel answerbox structure. */
+typedef struct kbox {
+	/** The answerbox itself. */
+	answerbox_t box;
+	/** Thread used to service the answerbox. */
+	struct thread *thread;
+	/** Kbox thread creation vs. begin of cleanup mutual exclusion. */
+	mutex_t cleanup_lock;
+	/** True if cleanup of kbox has already started. */
+	bool finished;
+} kbox_t;
+
 extern int ipc_connect_kbox(task_id_t);
 extern void ipc_kbox_cleanup(void);
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 0aa1665b932e64c1786b7cc2ee1964f9694cfd8b)
+++ kernel/generic/include/proc/task.h	(revision 31696b4fbd84b5c8090a758e9a35ba49a9156b52)
@@ -54,4 +54,5 @@
 #include <proc/scheduler.h>
 #include <udebug/udebug.h>
+#include <ipc/kbox.h>
 
 #define TASK_NAME_BUFLEN	20
@@ -99,17 +100,11 @@
 
 #ifdef CONFIG_UDEBUG
-	/** Debugging stuff */
+	/** Debugging stuff. */
 	udebug_task_t udebug;
 
-	/** Kernel answerbox */
-	answerbox_t kernel_box;
-	/** Thread used to service kernel answerbox */
-	struct thread *kb_thread;
-	/** Kbox thread creation vs. begin of cleanup mutual exclusion */
-	mutex_t kb_cleanup_lock;
-	/** True if cleanup of kbox has already started */
-	bool kb_finished;
+	/** Kernel answerbox. */
+	kbox_t kb;
 #endif
-	
+
 	/** Architecture specific task data. */
 	task_arch_t arch;
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 0aa1665b932e64c1786b7cc2ee1964f9694cfd8b)
+++ kernel/generic/src/ipc/kbox.c	(revision 31696b4fbd84b5c8090a758e9a35ba49a9156b52)
@@ -49,12 +49,18 @@
 	bool have_kb_thread;
 
-	/* Only hold kb_cleanup_lock while setting kb_finished - this is enough */
-	mutex_lock(&TASK->kb_cleanup_lock);
-	TASK->kb_finished = true;
-	mutex_unlock(&TASK->kb_cleanup_lock);
-
-	have_kb_thread = (TASK->kb_thread != NULL);
-
-	/* From now on nobody will try to connect phones or attach kbox threads */
+	/* 
+	 * Only hold kb.cleanup_lock while setting kb.finished -
+	 * this is enough.
+	 */
+	mutex_lock(&TASK->kb.cleanup_lock);
+	TASK->kb.finished = true;
+	mutex_unlock(&TASK->kb.cleanup_lock);
+
+	have_kb_thread = (TASK->kb.thread != NULL);
+
+	/*
+	 * From now on nobody will try to connect phones or attach
+	 * kbox threads
+	 */
 
 	/*
@@ -64,5 +70,5 @@
 	 * wake up and terminate.
 	 */
-	ipc_answerbox_slam_phones(&TASK->kernel_box, have_kb_thread);
+	ipc_answerbox_slam_phones(&TASK->kb.box, have_kb_thread);
 
 	/* 
@@ -78,16 +84,16 @@
 	
 	if (have_kb_thread) {
-		LOG("join kb_thread..\n");
-		thread_join(TASK->kb_thread);
-		thread_detach(TASK->kb_thread);
+		LOG("join kb.thread..\n");
+		thread_join(TASK->kb.thread);
+		thread_detach(TASK->kb.thread);
 		LOG("join done\n");
-		TASK->kb_thread = NULL;
-	}
-
-	/* Answer all messages in 'calls' and 'dispatched_calls' queues */
-	spinlock_lock(&TASK->kernel_box.lock);
-	ipc_cleanup_call_list(&TASK->kernel_box.dispatched_calls);
-	ipc_cleanup_call_list(&TASK->kernel_box.calls);
-	spinlock_unlock(&TASK->kernel_box.lock);
+		TASK->kb.thread = NULL;
+	}
+
+	/* Answer all messages in 'calls' and 'dispatched_calls' queues. */
+	spinlock_lock(&TASK->kb.box.lock);
+	ipc_cleanup_call_list(&TASK->kb.box.dispatched_calls);
+	ipc_cleanup_call_list(&TASK->kb.box.calls);
+	spinlock_unlock(&TASK->kb.box.lock);
 }
 
@@ -106,5 +112,5 @@
 	/* Was it our debugger, who hung up? */
 	if (call->sender == TASK->udebug.debugger) {
-		/* Terminate debugging session (if any) */
+		/* Terminate debugging session (if any). */
 		LOG("kbox: terminate debug session\n");
 		ipl = interrupts_disable();
@@ -119,5 +125,5 @@
 	LOG("kbox: continue with hangup message\n");
 	IPC_SET_RETVAL(call->data, 0);
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 
 	ipl = interrupts_disable();
@@ -131,11 +137,11 @@
 
 		/* Only detach kbox thread unless already terminating. */
-		mutex_lock(&TASK->kb_cleanup_lock);
-		if (&TASK->kb_finished == false) {
+		mutex_lock(&TASK->kb.cleanup_lock);
+		if (&TASK->kb.finished == false) {
 			/* Detach kbox thread so it gets freed from memory. */
-			thread_detach(TASK->kb_thread);
-			TASK->kb_thread = NULL;
+			thread_detach(TASK->kb.thread);
+			TASK->kb.thread = NULL;
 		}
-		mutex_unlock(&TASK->kb_cleanup_lock);
+		mutex_unlock(&TASK->kb.cleanup_lock);
 
 		LOG("phone list is empty\n");
@@ -167,5 +173,5 @@
 
 	while (!done) {
-		call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT,
+		call = ipc_wait_for_call(&TASK->kb.box, SYNCH_NO_TIMEOUT,
 			SYNCH_FLAGS_NONE);
 
@@ -202,8 +208,8 @@
  * Connect phone to a task kernel-box specified by id.
  *
- * Note that this is not completely atomic. For optimisation reasons,
- * The task might start cleaning up kbox after the phone has been connected
- * and before a kbox thread has been created. This must be taken into account
- * in the cleanup code.
+ * Note that this is not completely atomic. For optimisation reasons, the task
+ * might start cleaning up kbox after the phone has been connected and before
+ * a kbox thread has been created. This must be taken into account in the
+ * cleanup code.
  *
  * @return 		Phone id on success, or negative error code.
@@ -231,14 +237,14 @@
 	interrupts_restore(ipl);
 
-	mutex_lock(&ta->kb_cleanup_lock);
+	mutex_lock(&ta->kb.cleanup_lock);
 
 	if (atomic_predec(&ta->refcount) == 0) {
-		mutex_unlock(&ta->kb_cleanup_lock);
+		mutex_unlock(&ta->kb.cleanup_lock);
 		task_destroy(ta);
 		return ENOENT;
 	}
 
-	if (ta->kb_finished != false) {
-		mutex_unlock(&ta->kb_cleanup_lock);
+	if (ta->kb.finished != false) {
+		mutex_unlock(&ta->kb.cleanup_lock);
 		return EINVAL;
 	}
@@ -246,27 +252,28 @@
 	newphid = phone_alloc();
 	if (newphid < 0) {
-		mutex_unlock(&ta->kb_cleanup_lock);
+		mutex_unlock(&ta->kb.cleanup_lock);
 		return ELIMIT;
 	}
 
 	/* Connect the newly allocated phone to the kbox */
-	ipc_phone_connect(&TASK->phones[newphid], &ta->kernel_box);
-
-	if (ta->kb_thread != NULL) {
-		mutex_unlock(&ta->kb_cleanup_lock);
+	ipc_phone_connect(&TASK->phones[newphid], &ta->kb.box);
+
+	if (ta->kb.thread != NULL) {
+		mutex_unlock(&ta->kb.cleanup_lock);
 		return newphid;
 	}
 
 	/* Create a kbox thread */
-	kb_thread = thread_create(kbox_thread_proc, NULL, ta, 0, "kbox", false);
+	kb_thread = thread_create(kbox_thread_proc, NULL, ta, 0,
+	    "kbox", false);
 	if (!kb_thread) {
-		mutex_unlock(&ta->kb_cleanup_lock);
+		mutex_unlock(&ta->kb.cleanup_lock);
 		return ENOMEM;
 	}
 
-	ta->kb_thread = kb_thread;
+	ta->kb.thread = kb_thread;
 	thread_ready(kb_thread);
 
-	mutex_unlock(&ta->kb_cleanup_lock);
+	mutex_unlock(&ta->kb.cleanup_lock);
 
 	return newphid;
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 0aa1665b932e64c1786b7cc2ee1964f9694cfd8b)
+++ kernel/generic/src/proc/task.c	(revision 31696b4fbd84b5c8090a758e9a35ba49a9156b52)
@@ -165,8 +165,8 @@
 
 	/* Init kbox stuff */
-	ipc_answerbox_init(&ta->kernel_box, ta);
-	ta->kb_thread = NULL;
-	mutex_initialize(&ta->kb_cleanup_lock, MUTEX_PASSIVE);
-	ta->kb_finished = false;
+	ipc_answerbox_init(&ta->kb.box, ta);
+	ta->kb.thread = NULL;
+	mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);
+	ta->kb.finished = false;
 #endif
 
Index: kernel/generic/src/udebug/udebug_ipc.c
===================================================================
--- kernel/generic/src/udebug/udebug_ipc.c	(revision 0aa1665b932e64c1786b7cc2ee1964f9694cfd8b)
+++ kernel/generic/src/udebug/udebug_ipc.c	(revision 31696b4fbd84b5c8090a758e9a35ba49a9156b52)
@@ -74,5 +74,5 @@
 	if (rc < 0) {
 		IPC_SET_RETVAL(call->data, rc);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 		return;
 	}
@@ -84,5 +84,5 @@
 	if (rc != 0) {
 		IPC_SET_RETVAL(call->data, 0);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 	}
 }
@@ -100,5 +100,5 @@
 
 	IPC_SET_RETVAL(call->data, rc);
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -117,5 +117,5 @@
 
 	IPC_SET_RETVAL(call->data, rc);
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -136,5 +136,5 @@
 	if (rc < 0) {
 		IPC_SET_RETVAL(call->data, rc);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 		return;
 	}
@@ -155,5 +155,5 @@
 	rc = udebug_stop(t, call);
 	IPC_SET_RETVAL(call->data, rc);
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -183,5 +183,5 @@
 	if (rc < 0) {
 		IPC_SET_RETVAL(call->data, rc);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 		return;
 	}
@@ -210,5 +210,5 @@
 	call->buffer = buffer;
 
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -230,5 +230,5 @@
 	if (rc != EOK) {
 		IPC_SET_RETVAL(call->data, rc);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 		return;
 	}
@@ -248,5 +248,5 @@
 	call->buffer = buffer;
 
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -271,5 +271,5 @@
 	if (rc < 0) {
 		IPC_SET_RETVAL(call->data, rc);
-		ipc_answer(&TASK->kernel_box, call);
+		ipc_answer(&TASK->kb.box, call);
 		return;
 	}
@@ -283,5 +283,5 @@
 	call->buffer = buffer;
 
-	ipc_answer(&TASK->kernel_box, call);
+	ipc_answer(&TASK->kb.box, call);
 }
 
@@ -307,5 +307,5 @@
 		if (TASK->udebug.debugger != call->sender) {
 			IPC_SET_RETVAL(call->data, EINVAL);
-			ipc_answer(&TASK->kernel_box, call);
+			ipc_answer(&TASK->kb.box, call);
 			return;	
 		}
