Index: uspace/srv/devman/client_conn.c
===================================================================
--- uspace/srv/devman/client_conn.c	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/client_conn.c	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -726,5 +726,5 @@
 
 /** Function for handling connections from a client to the device manager. */
-void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
+void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	/* Accept connection. */
Index: uspace/srv/devman/client_conn.h
===================================================================
--- uspace/srv/devman/client_conn.h	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/client_conn.h	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -36,5 +36,5 @@
 #include "devman.h"
 
-extern void devman_connection_client(ipc_callid_t, ipc_call_t *);
+extern void devman_connection_client(ipc_callid_t, ipc_call_t *, void *);
 
 #endif
Index: uspace/srv/devman/driver.c
===================================================================
--- uspace/srv/devman/driver.c	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/driver.c	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -36,5 +36,4 @@
 #include <sys/stat.h>
 #include <io/log.h>
-#include <ipc/driver.h>
 #include <loc.h>
 #include <str_error.h>
@@ -573,11 +572,11 @@
 	
 	if (rc != EOK) {
-		/* TODO handle error */
-	}
-
-	/* Wait for answer from the driver. */
-	async_wait_for(req, &rc);
-
-	switch(rc) {
+		async_forget(req);
+	} else {
+		/* Wait for answer from the driver. */
+		async_wait_for(req, &rc);
+	}
+
+	switch (rc) {
 	case EOK:
 		dev->state = DEVICE_USABLE;
@@ -592,6 +591,4 @@
 	
 	dev->passed_to_driver = true;
-
-	return;
 }
 
Index: uspace/srv/devman/drv_conn.c
===================================================================
--- uspace/srv/devman/drv_conn.c	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/drv_conn.c	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -49,5 +49,4 @@
 #include <io/log.h>
 #include <ipc/devman.h>
-#include <ipc/driver.h>
 #include <loc.h>
 
@@ -131,5 +130,5 @@
 	}
 	/* FIXME: Work around problem with callback sessions */
-	async_sess_args_set(driver->sess, DRIVER_DEVMAN, 0, 0);
+	async_sess_args_set(driver->sess, INTERFACE_DDF_DEVMAN, 0, 0);
 	
 	log_msg(LOG_DEFAULT, LVL_NOTE,
@@ -587,5 +586,5 @@
 
 /** Function for handling connections from a driver to the device manager. */
-void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
+void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
 	client_t *client;
Index: uspace/srv/devman/drv_conn.h
===================================================================
--- uspace/srv/devman/drv_conn.h	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/drv_conn.h	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -37,5 +37,5 @@
 #include "devman.h"
 
-extern void devman_connection_driver(ipc_callid_t, ipc_call_t *);
+extern void devman_connection_driver(ipc_callid_t, ipc_call_t *, void *);
 
 #endif
Index: uspace/srv/devman/loc.c
===================================================================
--- uspace/srv/devman/loc.c	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/loc.c	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -59,6 +59,5 @@
 	}
 	
-	loc_service_register_with_iface(loc_pathname,
-	    &fun->service_id, INTERFACE_DDF_CLIENT);
+	loc_service_register(loc_pathname, &fun->service_id);
 	
 	tree_add_loc_function(tree, fun);
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 0dd16778197e5f50b6e77a71d9b8aeb33b2ad863)
+++ uspace/srv/devman/main.c	(revision 93d8022e9ee8dcf2dc81eb3c64004042947f578c)
@@ -49,5 +49,4 @@
 #include <io/log.h>
 #include <ipc/devman.h>
-#include <ipc/driver.h>
 #include <loc.h>
 
@@ -66,23 +65,23 @@
 dev_tree_t device_tree;
 
-static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
-    bool drv_to_parent)
+static void devman_connection_device(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
 {
 	devman_handle_t handle = IPC_GET_ARG2(*icall);
-	devman_handle_t fwd_h;
-	fun_node_t *fun = NULL;
 	dev_node_t *dev = NULL;
 	
-	fun = find_fun_node(&device_tree, handle);
-	if (fun == NULL)
+	fun_node_t *fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL) {
 		dev = find_dev_node(&device_tree, handle);
-	else {
+	} else {
 		fibril_rwlock_read_lock(&device_tree.rwlock);
+		
 		dev = fun->dev;
 		if (dev != NULL)
 			dev_add_ref(dev);
+		
 		fibril_rwlock_read_unlock(&device_tree.rwlock);
 	}
-
+	
 	/*
 	 * For a valid function to connect to we need a device. The root
@@ -97,6 +96,6 @@
 		goto cleanup;
 	}
-
-	if (fun == NULL && !drv_to_parent) {
+	
+	if (fun == NULL) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, NAME ": devman_forward error - cannot "
 		    "connect to handle %" PRIun ", refers to a device.",
@@ -106,19 +105,8 @@
 	}
 	
-	driver_t *driver = NULL;
-	
 	fibril_rwlock_read_lock(&device_tree.rwlock);
 	
-	if (drv_to_parent) {
-		/* Connect to parent function of a device (or device function). */
-		if (dev->pfun->dev != NULL)
-			driver = dev->pfun->dev->drv;
-		
-		fwd_h = dev->pfun->handle;
-	} else {
-		/* Connect to the specified function */
-		driver = dev->drv;
-		fwd_h = handle;
-	}
+	/* Connect to the specified function */
+	driver_t *driver = dev->drv;
 	
 	fibril_rwlock_read_unlock(&device_tree.rwlock);
@@ -130,10 +118,4 @@
 		goto cleanup;
 	}
-	
-	int method;
-	if (drv_to_parent)
-		method = DRIVER_DRIVER;
-	else
-		method = DRIVER_CLIENT;
 	
 	if (!driver->sess) {
@@ -143,5 +125,5 @@
 		goto cleanup;
 	}
-
+	
 	if (fun != NULL) {
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
@@ -155,5 +137,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(driver->sess);
-	async_forward_fast(iid, exch, method, fwd_h, 0, IPC_FF_NONE);
+	async_forward_fast(iid, exch, INTERFACE_DDF_CLIENT, handle, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
 	
@@ -166,20 +148,95 @@
 }
 
-/** Function for handling connections from a client forwarded by the location
- * service to the device manager. */
-static void devman_connection_loc(ipc_callid_t iid, ipc_call_t *icall)
-{
+static void devman_connection_parent(ipc_callid_t iid, ipc_call_t *icall,
+    void *arg)
+{
+	devman_handle_t handle = IPC_GET_ARG2(*icall);
+	dev_node_t *dev = NULL;
+	
+	fun_node_t *fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL) {
+		dev = find_dev_node(&device_tree, handle);
+	} else {
+		fibril_rwlock_read_lock(&device_tree.rwlock);
+		
+		dev = fun->dev;
+		if (dev != NULL)
+			dev_add_ref(dev);
+		
+		fibril_rwlock_read_unlock(&device_tree.rwlock);
+	}
+	
+	/*
+	 * For a valid function to connect to we need a device. The root
+	 * function, for example, has no device and cannot be connected to.
+	 * This means @c dev needs to be valid regardless whether we are
+	 * connecting to a device or to a function.
+	 */
+	if (dev == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding failed - no device or "
+		    "function with handle %" PRIun " was found.", handle);
+		async_answer_0(iid, ENOENT);
+		goto cleanup;
+	}
+	
+	driver_t *driver = NULL;
+	
+	fibril_rwlock_read_lock(&device_tree.rwlock);
+	
+	/* Connect to parent function of a device (or device function). */
+	if (dev->pfun->dev != NULL)
+		driver = dev->pfun->dev->drv;
+	
+	devman_handle_t fun_handle = dev->pfun->handle;
+	
+	fibril_rwlock_read_unlock(&device_tree.rwlock);
+	
+	if (driver == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \
+		    "the device %" PRIun " is not in usable state.", handle);
+		async_answer_0(iid, ENOENT);
+		goto cleanup;
+	}
+	
+	if (!driver->sess) {
+		log_msg(LOG_DEFAULT, LVL_ERROR,
+		    "Could not forward to driver `%s'.", driver->name);
+		async_answer_0(iid, EINVAL);
+		goto cleanup;
+	}
+	
+	if (fun != NULL) {
+		log_msg(LOG_DEFAULT, LVL_DEBUG,
+		    "Forwarding request for `%s' function to driver `%s'.",
+		    fun->pathname, driver->name);
+	} else {
+		log_msg(LOG_DEFAULT, LVL_DEBUG,
+		    "Forwarding request for `%s' device to driver `%s'.",
+		    dev->pfun->pathname, driver->name);
+	}
+	
+	async_exch_t *exch = async_exchange_begin(driver->sess);
+	async_forward_fast(iid, exch, INTERFACE_DDF_DRIVER, fun_handle, 0, IPC_FF_NONE);
+	async_exchange_end(exch);
+	
+cleanup:
+	if (dev != NULL)
+		dev_del_ref(dev);
+	
+	if (fun != NULL)
+		fun_del_ref(fun);
+}
+
+static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	iface_t iface = IPC_GET_ARG1(*icall);
 	service_id_t service_id = IPC_GET_ARG2(*icall);
-	fun_node_t *fun;
-	dev_node_t *dev;
-	devman_handle_t handle;
-	driver_t *driver;
-
-	fun = find_loc_tree_function(&device_tree, service_id);
+	
+	fun_node_t *fun = find_loc_tree_function(&device_tree, service_id);
 	
 	fibril_rwlock_read_lock(&device_tree.rwlock);
 	
-	if (fun == NULL || fun->dev == NULL || fun->dev->drv == NULL) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "devman_connection_loc(): function "
+	if ((fun == NULL) || (fun->dev == NULL) || (fun->dev->drv == NULL)) {
+		log_msg(LOG_DEFAULT, LVL_WARN, "devman_forward(): function "
 		    "not found.\n");
 		fibril_rwlock_read_unlock(&device_tree.rwlock);
@@ -188,49 +245,19 @@
 	}
 	
-	dev = fun->dev;
-	driver = dev->drv;
-	handle = fun->handle;
+	dev_node_t *dev = fun->dev;
+	driver_t *driver = dev->drv;
+	devman_handle_t handle = fun->handle;
 	
 	fibril_rwlock_read_unlock(&device_tree.rwlock);
 	
 	async_exch_t *exch = async_exchange_begin(driver->sess);
-	async_forward_fast(iid, exch, DRIVER_CLIENT, handle, 0,
-	    IPC_FF_NONE);
+	async_forward_fast(iid, exch, iface, handle, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
 	
 	log_msg(LOG_DEFAULT, LVL_DEBUG,
-	    "Forwarding loc service request for `%s' function to driver `%s'.",
+	    "Forwarding service request for `%s' function to driver `%s'.",
 	    fun->pathname, driver->name);
-
+	
 	fun_del_ref(fun);
-}
-
-/** Function for handling connections to device manager. */
-static void devman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	/* Select port. */
-	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
-	case DEVMAN_DRIVER:
-		devman_connection_driver(iid, icall);
-		break;
-	case DEVMAN_CLIENT:
-		devman_connection_client(iid, icall);
-		break;
-	case DEVMAN_CONNECT_TO_DEVICE:
-		/* Connect client to selected device. */
-		devman_forward(iid, icall, false);
-		break;
-	case INTERFACE_DDF_CLIENT:
-		/* Someone connected through loc node. */
-		devman_connection_loc(iid, icall);
-		break;
-	case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
-		/* Connect client to selected device. */
-		devman_forward(iid, icall, true);
-		break;
-	default:
-		/* No such interface */
-		async_answer_0(iid, ENOENT);
-	}
 }
 
@@ -298,5 +325,27 @@
 	async_set_client_data_constructor(devman_client_data_create);
 	async_set_client_data_destructor(devman_client_data_destroy);
-	async_set_fallback_port_handler(devman_connection, NULL);
+	
+	port_id_t port;
+	rc = async_create_port(INTERFACE_DDF_DRIVER,
+	    devman_connection_driver, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DDF_CLIENT,
+	    devman_connection_client, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DEVMAN_DEVICE,
+	    devman_connection_device, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	rc = async_create_port(INTERFACE_DEVMAN_PARENT,
+	    devman_connection_parent, NULL, &port);
+	if (rc != EOK)
+		return rc;
+	
+	async_set_fallback_port_handler(devman_forward, NULL);
 	
 	if (!devman_init()) {
