Index: uspace/lib/c/generic/async/client.c
===================================================================
--- uspace/lib/c/generic/async/client.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/async/client.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -99,5 +99,4 @@
 #include <async.h>
 #include "../private/async.h"
-#include "../private/ns.h"
 #undef _LIBC_ASYNC_C_
 
@@ -114,6 +113,6 @@
 #include <stdbool.h>
 #include <stdlib.h>
+#include <stdatomic.h>
 #include <mem.h>
-#include <stdlib.h>
 #include <macros.h>
 #include <as.h>
@@ -174,8 +173,7 @@
     sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
 {
-	async_sess_t *session = (async_sess_t *) malloc(sizeof(async_sess_t));
+	async_sess_t *session = (async_sess_t *) calloc(1, sizeof(async_sess_t));
 
 	if (session != NULL) {
-		session->iface = 0;
 		session->mgmt = mgmt;
 		session->phone = phone;
@@ -189,6 +187,4 @@
 		list_initialize(&session->exch_list);
 		fibril_mutex_initialize(&session->mutex);
-		atomic_set(&session->refcnt, 0);
-		&session.exchanges = 0;
 	} else {
 		errno = ENOMEM;
@@ -198,5 +194,5 @@
 }
 
-int async_session_phone(async_sess_t *sess)
+cap_phone_handle_t async_session_phone(async_sess_t *sess)
 {
 	return sess->phone;
@@ -859,8 +855,9 @@
 	}
 
-	async_sess_t *sess = create_session(phone, mgmt, iface, arg2, arg3);
+	async_sess_t *sess = create_session(phone, iface & IFACE_EXCHANGE_MASK, iface, arg2, arg3);
 	if (sess == NULL) {
 		ipc_hangup(phone);
 	}
+	sess->iface = iface;
 
 	return sess;
@@ -912,12 +909,12 @@
 	if (rc != EOK) {
 		errno = rc;
-		free(sess);
 		return NULL;
 	}
 
-	async_sess_t *sess = create_session(phone, mgmt, iface, arg2, arg3);
+	async_sess_t *sess = create_session(phone, iface & IFACE_EXCHANGE_MASK, iface, arg2, arg3);
 	if (sess == NULL) {
 		ipc_hangup(phone);
 	}
+	sess->iface = iface;
 
 	return sess;
Index: uspace/lib/c/generic/async/server.c
===================================================================
--- uspace/lib/c/generic/async/server.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/async/server.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -216,5 +216,19 @@
 }
 
-static async_client_conn_t implicit_connection = NULL;
+static async_port_handler_t implicit_connection = NULL;
+
+/** Setter for implicit_connection function pointer.
+ *
+ * @param conn Function that will implement a new connection fibril for
+ *             unrouted calls.
+ *
+ */
+void async_set_implicit_connection(async_port_handler_t conn)
+{
+        assert(implicit_connection == NULL);
+        implicit_connection = conn;
+}
+
+
 static fibril_rmutex_t client_mutex;
 static hash_table_t client_hash_table;
@@ -969,6 +983,11 @@
 		return;
 	} else if (implicit_connection != NULL) {
-		async_new_connection(call->in_task_id, call->in_phone_hash,
-		    callid, call, implicit_connection, NULL);
+		connection_t *conn = calloc(1, sizeof(connection_t));
+		if (!conn) {
+			ipc_answer_0(call->cap_handle, ENOMEM);
+			return;
+		}
+
+		async_new_connection(conn, call->task_id, call, implicit_connection, NULL);
 		return;
 	}
@@ -1749,5 +1768,5 @@
 	async_sess_t *sess = create_session(phandle, mgmt, 0, 0, 0);
 	if (sess == NULL) {
-		ipc_hangup(phone);
+		ipc_hangup(phandle);
 		async_answer_0(&call, errno);
 	} else {
Index: uspace/lib/c/generic/ns.c
===================================================================
--- uspace/lib/c/generic/ns.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/ns.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -59,10 +59,4 @@
 }
 
-/*
- * XXX ns does not know about session_primary, so we create an extra session for
- * actual communicaton
- */
-static async_sess_t *sess_primary = NULL;
-
 errno_t service_register(service_t service, iface_t iface,
     async_port_handler_t handler, void *data)
@@ -96,9 +90,5 @@
 	async_set_fallback_port_handler(handler, data);
 
-	async_sess_t *sess = get_session_primary();
-	if (sess == NULL)
-		return EIO;
-
-	async_exch_t *exch = async_exchange_begin(sess);
+	async_exch_t *exch = ns_exchange_begin();
 
 	ipc_call_t answer;
@@ -106,5 +96,5 @@
 	errno_t rc = async_connect_to_me(exch, INTERFACE_ANY, service, 0);
 
-	async_exchange_end(exch);
+	ns_exchange_end(exch);
 
 	if (rc != EOK) {
@@ -138,5 +128,5 @@
 	async_sess_args_set(sess, iface, arg3, 0);
 
-	return csess;
+	return sess;
 }
 
@@ -164,5 +154,5 @@
 errno_t ns_ping(void)
 {
-	async_exch_t *exch = ns_exchange_begin(sess);
+	async_exch_t *exch = ns_exchange_begin();
 	errno_t rc = async_req_0_0(exch, NS_PING);
 	ns_exchange_end(exch);
Index: uspace/lib/c/generic/private/async.h
===================================================================
--- uspace/lib/c/generic/private/async.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/private/async.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -42,4 +42,5 @@
 #include <time.h>
 #include <stdbool.h>
+#include <stdatomic.h>
 
 /** Session data */
@@ -106,7 +107,7 @@
 
 extern void async_reply_received(ipc_call_t *);
-extern async_sess_t *create_session(int, exch_mgmt_t,
+extern async_sess_t *create_session(cap_phone_handle_t, exch_mgmt_t,
 	sysarg_t, sysarg_t, sysarg_t);
-extern int async_session_phone(async_sess_t *);
+extern cap_phone_handle_t async_session_phone(async_sess_t *);
 
 #endif
Index: uspace/lib/c/generic/private/taskman.h
===================================================================
--- uspace/lib/c/generic/private/taskman.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/private/taskman.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -36,5 +36,5 @@
 #define LIBC_PRIVATE_TASKMAN_H_
 
-#include <async.h>
+#include "async.h"
 
 extern async_sess_t *session_taskman;
Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/task.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -385,7 +385,7 @@
 	if (rc == EOK || rc == EINTR) {
 		if (wait->flags & TASK_WAIT_EXIT && texit)
-			*texit = ipc_get_arg1(wait->result);
+			*texit = ipc_get_arg1(&wait->result);
 		if (wait->flags & TASK_WAIT_RETVAL && retval)
-			*retval = ipc_get_arg2(wait->result);
+			*retval = ipc_get_arg2(&wait->result);
 		
 	}
@@ -394,5 +394,5 @@
 		/* Is there another wait to be done? Wait for it! */
 		int old_flags = wait->flags;
-		wait->flags = ipc_get_arg3(wait->result);
+		wait->flags = ipc_get_arg3(&wait->result);
 		if (wait->flags != 0 && (old_flags & TASK_WAIT_BOTH)) {
 			rc = task_setup_wait(wait->tid, wait);
@@ -438,5 +438,5 @@
 		return EIO;
 
-	errno_t rc = (int) async_req_2_0(exch, TASKMAN_RETVAL, val, wait_for_exit);
+	errno_t rc = async_req_2_0(exch, TASKMAN_RETVAL, val, wait_for_exit);
 	taskman_exchange_end(exch);
 	
Index: uspace/lib/c/generic/task_event.c
===================================================================
--- uspace/lib/c/generic/task_event.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/task_event.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -37,4 +37,5 @@
 #include <macros.h>
 #include <task.h>
+#include <assert.h>
 
 #include "private/taskman.h"
@@ -42,37 +43,36 @@
 static task_event_handler_t task_event_handler = NULL;
 
-static void taskman_task_event(ipc_callid_t iid, ipc_call_t *icall)
+static void taskman_task_event(ipc_call_t *icall)
 {
 	task_id_t tid = (task_id_t)
-	    MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
-	int flags = IPC_GET_ARG3(*icall);
-	task_exit_t texit = IPC_GET_ARG4(*icall);
-	int retval = IPC_GET_ARG5(*icall);
+	    MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall));
+	int flags = ipc_get_arg3(icall);
+	task_exit_t texit = ipc_get_arg4(icall);
+	int retval = ipc_get_arg5(icall);
 
 	task_event_handler(tid, flags, texit, retval);
 
-	async_answer_0(iid, EOK);
+	async_answer_0(icall, EOK);
 }
 
-static void taskman_event_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+static void taskman_event_conn(ipc_call_t *icall, void *arg)
 {
 	/* Accept connection */
-	async_answer_0(iid, EOK);
+	async_answer_0(icall, EOK);
 
 	while (true) {
 		ipc_call_t call;
-		ipc_callid_t callid = async_get_call(&call);
-
-		if (!IPC_GET_IMETHOD(call)) {
+		
+		if (!async_get_call(&call) || !ipc_get_imethod(&call)) {
 			/* Hangup, end of game */
 			break;
 		}
 
-		switch (IPC_GET_IMETHOD(call)) {
+		switch (ipc_get_imethod(&call)) {
 		case TASKMAN_EV_TASK:
-			taskman_task_event(callid, &call);
+			taskman_task_event(&call);
 			break;
 		default:
-			async_answer_0(callid, ENOTSUP);
+			async_answer_0(&call, ENOTSUP);
 			break;
 		}
@@ -83,5 +83,5 @@
  * Blocks, calls handler in another fibril
  */
-int task_register_event_handler(task_event_handler_t handler, bool past_events)
+errno_t task_register_event_handler(task_event_handler_t handler, bool past_events)
 {
 	/*
@@ -97,5 +97,7 @@
 	aid_t req = async_send_1(exch, TASKMAN_EVENT_CALLBACK, past_events, NULL);
 
-	int rc = async_connect_to_me(exch, 0, 0, 0, taskman_event_conn, NULL);
+	port_id_t port;
+	errno_t rc = async_create_callback_port(exch, INTERFACE_TASKMAN_CB, 0, 0,
+		taskman_event_conn, NULL, &port);
 	taskman_exchange_end(exch);
 
@@ -104,5 +106,5 @@
 	}
 
-	sysarg_t retval;
+	errno_t retval;
 	async_wait_for(req, &retval);
 	return retval;
Index: uspace/lib/c/generic/taskman.c
===================================================================
--- uspace/lib/c/generic/taskman.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/taskman.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -103,6 +103,6 @@
 	assert(exch);
 
-	async_sess_t *sess = async_connect_me_to(EXCHANGE_ATOMIC,
-	    exch, TASKMAN_CONNECT_TO_NS, 0, 0);
+	async_sess_t *sess = async_connect_me_to(exch, INTERFACE_NS,
+		TASKMAN_CONNECT_TO_NS, 0);
 	async_exchange_end(exch);
 
@@ -116,6 +116,6 @@
 
 	async_exch_t *exch = async_exchange_begin(session_taskman);
-	async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE,
-	    exch, TASKMAN_CONNECT_TO_LOADER, 0, 0);
+	async_sess_t *sess = async_connect_me_to(exch, INTERFACE_LOADER,
+	    TASKMAN_CONNECT_TO_LOADER, 0);
 	async_exchange_end(exch);
 
@@ -136,11 +136,10 @@
  * @return EOK on success, otherwise propagated error code
  */
-int taskman_intro_loader(void)
+errno_t taskman_intro_loader(void)
 {
 	assert(session_taskman);
 
 	async_exch_t *exch = async_exchange_begin(session_taskman);
-	int rc = async_connect_to_me(
-	    exch, TASKMAN_LOADER_CALLBACK, 0, 0, NULL, NULL);
+	errno_t rc = async_connect_to_me(exch, INTERFACE_LOADER, TASKMAN_LOADER_CALLBACK, 0);
 	async_exchange_end(exch);
 
@@ -152,5 +151,5 @@
  * @return EOK on success, otherwise propagated error code
  */
-int taskman_intro_ns(void)
+errno_t taskman_intro_ns(void)
 {
 	assert(session_taskman);
@@ -159,5 +158,5 @@
 	aid_t req = async_send_0(exch, TASKMAN_I_AM_NS, NULL);
 
-	int rc = async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
+	errno_t rc = async_connect_to_me(exch, INTERFACE_NS, 0, 0);
 	taskman_exchange_end(exch);
 
@@ -166,5 +165,5 @@
 	}
 
-	sysarg_t retval;
+	errno_t retval;
 	async_wait_for(req, &retval);
 	return retval;
Index: uspace/lib/c/generic/taskman_noasync.c
===================================================================
--- uspace/lib/c/generic/taskman_noasync.c	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/generic/taskman_noasync.c	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -33,9 +33,10 @@
  */
 
-#define LIBC_ASYNC_C_
-#include <ipc/ipc.h>
 #include "private/async.h"
 #include "private/taskman.h"
-#undef LIBC_ASYNC_C_
+
+#undef _LIBC_ASYNC_H_
+#include <ipc/ipc.h>
+#define _LIBC_ASYNC_H_
 
 #include <errno.h>
@@ -50,12 +51,12 @@
  * @return EOK on success, otherwise propagated error code
  */
-int taskman_intro_ns_noasync(void)
+errno_t taskman_intro_ns_noasync(void)
 {
 	assert(session_taskman);
-	int phone = async_session_phone(session_taskman);
+	cap_phone_handle_t phone = async_session_phone(session_taskman);
 
-	ipc_call_async_0(phone, TASKMAN_I_AM_NS, NULL, NULL, false);
+	ipc_call_async_0(phone, TASKMAN_I_AM_NS, NULL);
 
-	ipc_call_async_3(phone, IPC_M_CONNECT_TO_ME, 0, 0, 0, NULL, NULL, false);
+	ipc_call_async_3(phone, IPC_M_CONNECT_TO_ME, 0, 0, 0, NULL);
 
 	/*
@@ -67,12 +68,11 @@
 
 
-void task_retval_noasync(int retval)
+void task_retval_noasync(errno_t retval)
 {
 	assert(session_taskman);
-	int phone = async_session_phone(session_taskman);
+	cap_phone_handle_t phone = async_session_phone(session_taskman);
 
 	/* Just send it and don't wait for an answer. */
-	ipc_call_async_2(phone, TASKMAN_RETVAL, retval, false,
-	    NULL, NULL, false);
+	ipc_call_async_2(phone, TASKMAN_RETVAL, retval, false, NULL);
 }
 
Index: uspace/lib/c/include/adt/dyn_array.h
===================================================================
--- uspace/lib/c/include/adt/dyn_array.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/include/adt/dyn_array.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -41,5 +41,5 @@
 typedef struct {
 	/** Data buffer of array */
-	uint8_t *_data;
+	void *_data;
 	/** Size on bytes of a single item */
 	size_t _item_size;
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/include/async.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -132,5 +132,5 @@
 extern void async_put_client_data_by_id(task_id_t);
 
-extern void async_set_implicit_connection(async_client_conn_t);
+extern void async_set_implicit_connection(async_port_handler_t);
 
 extern errno_t async_create_port(iface_t, async_port_handler_t, void *,
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/include/ipc/services.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -55,4 +55,5 @@
 #define SERVICE_NAME_CLIPBOARD "clipboard"
 #define SERVICE_NAME_CORECFG  "corecfg"
+#define SERVICE_NAME_DEVMAN   "devman"
 #define SERVICE_NAME_DHCP     "net/dhcp"
 #define SERVICE_NAME_DNSR     "net/dnsr"
Index: uspace/lib/c/include/task.h
===================================================================
--- uspace/lib/c/include/task.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/include/task.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -76,5 +76,5 @@
 
 /* Implemented in task_event.c */
-extern int task_register_event_handler(task_event_handler_t, bool);
+extern errno_t task_register_event_handler(task_event_handler_t, bool);
 
 #endif
Index: uspace/lib/c/include/taskman.h
===================================================================
--- uspace/lib/c/include/taskman.h	(revision 8d74fdd2c255a9b8d91060f48eb2a6ff6cc5ad0c)
+++ uspace/lib/c/include/taskman.h	(revision 241f19855d1d9af65e95690ac5eb1dd1facffd0c)
@@ -40,8 +40,8 @@
 /* Internal functions to be used by loader only */
 extern async_sess_t *taskman_get_session(void);
-extern int taskman_intro_loader(void);
+extern errno_t taskman_intro_loader(void);
 
 /* Internal functions to be used by NS only */
-extern int taskman_intro_ns(void);
+extern errno_t taskman_intro_ns(void);
 
 #endif
