Index: libc/generic/async.c
===================================================================
--- libc/generic/async.c	(revision 79460ae08ef89a29aa03f465592f472e382429b9)
+++ libc/generic/async.c	(revision 44c6d88d97fb845af719b8a78de9f944baccc78e)
@@ -270,4 +270,14 @@
 }
 
+/** Function that gets created on interrupt receival
+ *
+ * This function is defined as a weak symbol - to be redefined in
+ * user code.
+ */
+void interrupt_received(ipc_call_t *call)
+{
+}
+
+
 /** Wrapper for client connection thread
  *
@@ -309,4 +319,5 @@
  * threads.
  *
+ * @param in_phone_hash Identification of the incoming connection
  * @param callid Callid of the IPC_M_CONNECT_ME_TO packet
  * @param call Call data of the opening packet
@@ -315,5 +326,6 @@
  * @return New thread id
  */
-pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call,
+pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, 
+			     ipc_call_t *call,
 			     void (*cthread)(ipc_callid_t,ipc_call_t *))
 {
@@ -327,5 +339,5 @@
 		return NULL;
 	}
-	conn->in_phone_hash = IPC_GET_ARG3(*call);
+	conn->in_phone_hash = in_phone_hash;
 	list_initialize(&conn->msg_queue);
 	conn->ptid = psthread_create(connection_thread, conn);
@@ -354,17 +366,21 @@
 static void handle_call(ipc_callid_t callid, ipc_call_t *call)
 {
+	/* Unrouted call - do some default behaviour */
+	switch (IPC_GET_METHOD(*call)) {
+	case IPC_M_INTERRUPT:
+		interrupt_received(call);
+		return;
+	case IPC_M_CONNECT_ME_TO:
+		/* Open new connection with thread etc. */
+		async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection);
+		return;
+	}
+
+	/* Try to route call through connection tables */
 	if (route_call(callid, call))
 		return;
 
-	switch (IPC_GET_METHOD(*call)) {
-	case IPC_M_INTERRUPT:
-		break;
-	case IPC_M_CONNECT_ME_TO:
-		/* Open new connection with thread etc. */
-		async_new_connection(callid, call, client_connection);
-		break;
-	default:
-		ipc_answer_fast(callid, EHANGUP, 0, 0);
-	}
+	/* Unknown call from unknown phone - hang it up */
+	ipc_answer_fast(callid, EHANGUP, 0, 0);
 }
 
@@ -622,2 +638,28 @@
 }
 
+/** Wait specified time, but in the meantime handle incoming events
+ *
+ * @param timeout Time in microseconds to wait
+ */
+void async_usleep(suseconds_t timeout)
+{
+	amsg_t *msg;
+	
+	msg = malloc(sizeof(*msg));
+	if (!msg)
+		return;
+
+	msg->ptid = psthread_get_id();
+	msg->active = 0;
+	msg->has_timeout = 1;
+
+	gettimeofday(&msg->expires, NULL);
+	tv_add(&msg->expires, timeout);
+
+	futex_down(&async_futex);
+	insert_timeout(msg);
+	/* Leave locked async_futex when entering this function */
+	psthread_schedule_next_adv(PS_TO_MANAGER);
+	/* futex is up automatically after psthread_schedule_next...*/
+	free(msg);
+}
Index: libc/generic/io/stream.c
===================================================================
--- libc/generic/io/stream.c	(revision 79460ae08ef89a29aa03f465592f472e382429b9)
+++ libc/generic/io/stream.c	(revision 44c6d88d97fb845af719b8a78de9f944baccc78e)
@@ -65,6 +65,5 @@
 	if (console_phone < 0) {
 		while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
-			volatile int a;
-			for (a = 0; a < 1048576; a++);
+			usleep(10000);
 		}
 	}
Index: libc/generic/time.c
===================================================================
--- libc/generic/time.c	(revision 79460ae08ef89a29aa03f465592f472e382429b9)
+++ libc/generic/time.c	(revision 44c6d88d97fb845af719b8a78de9f944baccc78e)
@@ -32,4 +32,7 @@
 #include <stdio.h>
 #include <arch/barrier.h>
+#include <unistd.h>
+#include <atomic.h>
+#include <futex.h>
 
 #include <sysinfo.h>
@@ -94,2 +97,11 @@
 	return 0;
 }
+
+/** Wait unconditionally for specified miliseconds */
+void usleep(unsigned long usec)
+{
+	atomic_t futex = FUTEX_INITIALIZER;
+
+	futex_initialize(&futex,0);
+	futex_down_timeout(&futex, usec, 0);
+}
Index: libc/include/async.h
===================================================================
--- libc/include/async.h	(revision 79460ae08ef89a29aa03f465592f472e382429b9)
+++ libc/include/async.h	(revision 44c6d88d97fb845af719b8a78de9f944baccc78e)
@@ -14,14 +14,16 @@
 ipc_callid_t async_get_call(ipc_call_t *data);
 
-pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call,
-			     void (*cthread)(ipc_callid_t,ipc_call_t *));
 aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
 		   ipc_call_t *dataptr);
 void async_wait_for(aid_t amsgid, ipcarg_t *result);
 int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
-
+pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, 
+			     ipc_call_t *call,
+			     void (*cthread)(ipc_callid_t,ipc_call_t *));
+void async_usleep(suseconds_t timeout);
 
 /* Should be defined by application */
 void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
+void interrupt_received(ipc_call_t *call)  __attribute__((weak));
 
 #endif
Index: libc/include/unistd.h
===================================================================
--- libc/include/unistd.h	(revision 79460ae08ef89a29aa03f465592f472e382429b9)
+++ libc/include/unistd.h	(revision 44c6d88d97fb845af719b8a78de9f944baccc78e)
@@ -39,4 +39,5 @@
 extern void _exit(int status);
 void *sbrk(ssize_t incr);
+void usleep(unsigned long usec);
 
 #endif
