Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 05e69c59b06df4165bbd86304590e9d5f3964437)
+++ kernel/generic/src/ipc/kbox.c	(revision 50e5b255c0a320ca1756e869899101e74bba6d6f)
@@ -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;
