Index: contrib/arch/kernel/kernel.adl
===================================================================
--- contrib/arch/kernel/kernel.adl	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ contrib/arch/kernel/kernel.adl	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -203,8 +203,8 @@
 		
 		/* Connect an IRQ handler to the current task */
-		sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t method, irq_code_t *ucode);
+		sysarg_t sys_register_irq(inr_t inr, devno_t devno, sysarg_t method, irq_code_t *ucode);
 		
 		/* Disconnect an IRQ handler from the current task */
-		sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
+		sysarg_t sys_unregister_irq(inr_t inr, devno_t devno);
 	protocol:
 		(
@@ -213,6 +213,6 @@
 			?sys_device_assign_devno +
 			?sys_preempt_control +
-			?sys_ipc_register_irq +
-			?sys_ipc_unregister_irq
+			?sys_register_irq +
+			?sys_unregister_irq
 		)*
 };
Index: contrib/arch/uspace/lib/libc/protocol
===================================================================
--- contrib/arch/uspace/lib/libc/protocol	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ contrib/arch/uspace/lib/libc/protocol	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,6 +34,6 @@
 	!sys_ddi.sys_device_assign_devno +
 	!sys_ddi.sys_preempt_control +
-	!sys_ddi.sys_ipc_register_irq +
-	!sys_ddi.sys_ipc_unregister_irq +
+	!sys_ddi.sys_register_irq +
+	!sys_ddi.sys_unregister_irq +
 	!sys_sysinfo.sys_sysinfo_valid +
 	!sys_sysinfo.sys_sysinfo_value +
Index: kernel/arch/arm32/src/mach/gta02/gta02.c
===================================================================
--- kernel/arch/arm32/src/mach/gta02/gta02.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/arch/arm32/src/mach/gta02/gta02.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -174,4 +174,5 @@
 		fb_parea.pbase = GTA02_FB_BASE;
 		fb_parea.frames = 150;
+		fb_parea.unpriv = false;
 		ddi_parea_register(&fb_parea);
 	}
Index: kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
===================================================================
--- kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -300,4 +300,5 @@
 		fb_parea.pbase = ICP_FB;
 		fb_parea.frames = 300;
+		fb_parea.unpriv = false;
 		ddi_parea_register(&fb_parea);
 	}
Index: kernel/arch/ia32/_link.ld.in
===================================================================
--- kernel/arch/ia32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/arch/ia32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -49,7 +49,19 @@
 	}
 	
+#ifdef CONFIG_LINE_DEBUG
+	.comment 0 : { *(.comment); }
+	.debug_abbrev 0 : { *(.debug_abbrev); }
+	.debug_aranges 0 : { *(.debug_aranges); }
+	.debug_info 0 : { *(.debug_info); }
+	.debug_line 0 : { *(.debug_line); }
+	.debug_loc 0 : { *(.debug_loc); }
+	.debug_pubnames 0 : { *(.debug_pubnames); }
+	.debug_pubtypes 0 : { *(.debug_pubtypes); }
+	.debug_ranges 0 : { *(.debug_ranges); }
+	.debug_str 0 : { *(.debug_str); }
+#endif
+	
 	/DISCARD/ : {
-		*(.note.GNU-stack);
-		*(.comment);
+		*(*);
 	}
 	
Index: kernel/arch/mips32/src/mm/tlb.c
===================================================================
--- kernel/arch/mips32/src/mm/tlb.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/arch/mips32/src/mm/tlb.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -557,6 +557,7 @@
 	entry_hi_t hi, hi_save;
 	tlb_index_t index;
-
-	ASSERT(asid != ASID_INVALID);
+	
+	if (asid == ASID_INVALID)
+		return;
 
 	hi_save.value = cp0_entry_hi_read();
Index: kernel/arch/sparc64/src/drivers/niagara.c
===================================================================
--- kernel/arch/sparc64/src/drivers/niagara.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/arch/sparc64/src/drivers/niagara.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -216,4 +216,5 @@
 	outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer));
 	outbuf_parea.frames = 1;
+	outbuf_parea.unpriv = false;
 	ddi_parea_register(&outbuf_parea);
 
@@ -221,4 +222,5 @@
 	inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer));
 	inbuf_parea.frames = 1;
+	inbuf_parea.unpriv = false;
 	ddi_parea_register(&inbuf_parea);
 
Index: kernel/generic/include/ddi/ddi.h
===================================================================
--- kernel/generic/include/ddi/ddi.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/ddi/ddi.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,8 +43,9 @@
 /** Structure representing contiguous physical memory area. */
 typedef struct {
-	uintptr_t pbase;    /**< Physical base of the area. */
-	pfn_t frames;       /**< Number of frames in the area. */
+	link_t link;      /**< Linked list link */
 	
-	link_t link;        /**< Linked list link */
+	uintptr_t pbase;  /**< Physical base of the area. */
+	pfn_t frames;     /**< Number of frames in the area. */
+	bool unpriv;      /**< Allow mapping by unprivileged tasks. */
 } parea_t;
 
@@ -60,5 +61,4 @@
 extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
 
-
 #endif
 
Index: kernel/generic/include/ipc/event_types.h
===================================================================
--- kernel/generic/include/ipc/event_types.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/ipc/event_types.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,5 @@
 	/** Returning from kernel console to userspace */
 	EVENT_KCONSOLE,
-	/** A thread has faulted and will be terminated */
+	/** A task/thread has faulted and will be terminated */
 	EVENT_FAULT,
 	EVENT_END
Index: kernel/generic/include/ipc/sysipc.h
===================================================================
--- kernel/generic/include/ipc/sysipc.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/ipc/sysipc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -56,6 +56,6 @@
     unsigned int);
 extern sysarg_t sys_ipc_hangup(sysarg_t);
-extern sysarg_t sys_ipc_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *);
-extern sysarg_t sys_ipc_unregister_irq(inr_t, devno_t);
+extern sysarg_t sys_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *);
+extern sysarg_t sys_unregister_irq(inr_t, devno_t);
 
 #ifdef __32_BITS__
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/mm/as.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -115,17 +115,19 @@
 	
 	/**
-	 * Number of processors on wich is this address space active.
-	 * Protected by asidlock.
+	 * Number of processors on which this
+	 * address space is active. Protected by
+	 * asidlock.
 	 */
 	size_t cpu_refcount;
 	
-	/**
-	 * Address space identifier.
-	 * Constant on architectures that do not support ASIDs.
-	 * Protected by asidlock.
+	/** Address space identifier.
+	 *
+	 * Constant on architectures that do not
+	 * support ASIDs. Protected by asidlock.
+	 *
 	 */
 	asid_t asid;
 	
-	/** Number of references (i.e tasks that reference this as). */
+	/** Number of references (i.e. tasks that reference this as). */
 	atomic_t refcount;
 	
@@ -199,24 +201,29 @@
 typedef struct {
 	mutex_t lock;
+	
 	/** Containing address space. */
 	as_t *as;
 	
-	/**
-	 * Flags related to the memory represented by the address space area.
-	 */
+	/** Memory flags. */
 	unsigned int flags;
 	
-	/** Attributes related to the address space area itself. */
+	/** Address space area attributes. */
 	unsigned int attributes;
-	/** Size of this area in multiples of PAGE_SIZE. */
+	
+	/** Number of pages in the area. */
 	size_t pages;
+	
+	/** Number of resident pages in the area. */
+	size_t resident;
+	
 	/** Base address of this area. */
 	uintptr_t base;
+	
 	/** Map of used space. */
 	btree_t used_space;
 	
 	/**
-	 * If the address space area has been shared, this pointer will
-	 * reference the share info structure.
+	 * If the address space area is shared. this is
+	 * a reference to the share info structure.
 	 */
 	share_info_t *sh_info;
@@ -261,7 +268,6 @@
 extern bool as_area_check_access(as_area_t *, pf_access_t);
 extern size_t as_area_get_size(uintptr_t);
-extern int used_space_insert(as_area_t *, uintptr_t, size_t);
-extern int used_space_remove(as_area_t *, uintptr_t, size_t);
-
+extern bool used_space_insert(as_area_t *, uintptr_t, size_t);
+extern bool used_space_remove(as_area_t *, uintptr_t, size_t);
 
 /* Interface to be implemented by architectures. */
@@ -307,4 +313,5 @@
 extern sysarg_t sys_as_area_change_flags(uintptr_t, unsigned int);
 extern sysarg_t sys_as_area_destroy(uintptr_t);
+extern sysarg_t sys_as_get_unmapped_area(uintptr_t, size_t);
 
 /* Introspection functions. */
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/proc/task.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -131,4 +131,5 @@
 extern task_t *task_find_by_id(task_id_t);
 extern int task_kill(task_id_t);
+extern void task_kill_self(bool) __attribute__((noreturn));
 extern void task_get_accounting(task_t *, uint64_t *, uint64_t *);
 extern void task_print_list(bool);
@@ -155,4 +156,5 @@
 extern sysarg_t sys_task_set_name(const char *, size_t);
 extern sysarg_t sys_task_kill(task_id_t *);
+extern sysarg_t sys_task_exit(sysarg_t);
 
 #endif
Index: kernel/generic/include/syscall/syscall.h
===================================================================
--- kernel/generic/include/syscall/syscall.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/syscall/syscall.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -48,4 +48,5 @@
 	SYS_TASK_SET_NAME,
 	SYS_TASK_KILL,
+	SYS_TASK_EXIT,
 	SYS_PROGRAM_SPAWN_LOADER,
 	
@@ -58,4 +59,5 @@
 	SYS_AS_AREA_CHANGE_FLAGS,
 	SYS_AS_AREA_DESTROY,
+	SYS_AS_GET_UNMAPPED_AREA,
 	
 	SYS_PAGE_FIND_MAPPING,
@@ -72,6 +74,4 @@
 	SYS_IPC_POKE,
 	SYS_IPC_HANGUP,
-	SYS_IPC_REGISTER_IRQ,
-	SYS_IPC_UNREGISTER_IRQ,
 	SYS_IPC_CONNECT_KBOX,
 	
@@ -84,4 +84,6 @@
 	SYS_PHYSMEM_MAP,
 	SYS_IOSPACE_ENABLE,
+	SYS_REGISTER_IRQ,
+	SYS_UNREGISTER_IRQ,
 	
 	SYS_SYSINFO_GET_TAG,
Index: kernel/generic/include/udebug/udebug.h
===================================================================
--- kernel/generic/include/udebug/udebug.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/include/udebug/udebug.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,144 +36,150 @@
 #define KERN_UDEBUG_H_
 
+#define UDEBUG_EVMASK(event)  (1 << ((event) - 1))
+
+typedef enum { /* udebug_method_t */
+	
+	/** Start debugging the recipient.
+	 *
+	 * Causes all threads in the receiving task to stop. When they
+	 * are all stoped, an answer with retval 0 is generated.
+	 *
+	 */
+	UDEBUG_M_BEGIN = 1,
+	
+	/** Finish debugging the recipient.
+	 *
+	 * Answers all pending GO and GUARD messages.
+	 *
+	 */
+	UDEBUG_M_END,
+	
+	/** Set which events should be captured. */
+	UDEBUG_M_SET_EVMASK,
+	
+	/** Make sure the debugged task is still there.
+	 *
+	 * This message is answered when the debugged task dies
+	 * or the debugging session ends.
+	 *
+	 */
+	UDEBUG_M_GUARD,
+	
+	/** Run a thread until a debugging event occurs.
+	 *
+	 * This message is answered when the thread stops
+	 * in a debugging event.
+	 *
+	 * - ARG2 - id of the thread to run
+	 *
+	 */
+	UDEBUG_M_GO,
+	
+	/** Stop a thread being debugged.
+	 *
+	 * Creates a special STOP event in the thread, causing
+	 * it to answer a pending GO message (if any).
+	 *
+	 */
+	UDEBUG_M_STOP,
+	
+	/** Read arguments of a syscall.
+	 *
+	 * - ARG2 - thread identification
+	 * - ARG3 - destination address in the caller's address space
+	 *
+	 */
+	UDEBUG_M_ARGS_READ,
+	
+	/** Read thread's userspace register state (istate_t).
+	 *
+	 * - ARG2 - thread identification
+	 * - ARG3 - destination address in the caller's address space
+	 *
+	 * or, on error, retval will be
+	 * - ENOENT - thread does not exist
+	 * - EBUSY - register state not available
+	 */
+	UDEBUG_M_REGS_READ,
+	
+	/** Read the list of the debugged tasks's threads.
+	 *
+	 * - ARG2 - destination address in the caller's address space
+	 * - ARG3 - size of receiving buffer in bytes
+	 *
+	 * The kernel fills the buffer with a series of sysarg_t values
+	 * (thread ids). On answer, the kernel will set:
+	 *
+	 * - ARG2 - number of bytes that were actually copied
+	 * - ARG3 - number of bytes of the complete data
+	 *
+	 */
+	UDEBUG_M_THREAD_READ,
+	
+	/** Read the name of the debugged task.
+	 *
+	 * - ARG2 - destination address in the caller's address space
+	 * - ARG3 - size of receiving buffer in bytes
+	 *
+	 * The kernel fills the buffer with a non-terminated string.
+	 *
+	 * - ARG2 - number of bytes that were actually copied
+	 * - ARG3 - number of bytes of the complete data
+	 *
+	 */
+	UDEBUG_M_NAME_READ,
+	
+	/** Read the list of the debugged task's address space areas.
+	 *
+	 * - ARG2 - destination address in the caller's address space
+	 * - ARG3 - size of receiving buffer in bytes
+	 *
+	 * The kernel fills the buffer with a series of as_area_info_t structures.
+	 * Upon answer, the kernel will set:
+	 *
+	 * - ARG2 - number of bytes that were actually copied
+	 * - ARG3 - number of bytes of the complete data
+	 *
+	 */
+	UDEBUG_M_AREAS_READ,
+	
+	/** Read the debugged tasks's memory.
+	 *
+	 * - ARG2 - destination address in the caller's address space
+	 * - ARG3 - source address in the recipient's address space
+	 * - ARG4 - size of receiving buffer in bytes
+	 *
+	 */
+	UDEBUG_M_MEM_READ
+} udebug_method_t;
+
+typedef enum {
+	UDEBUG_EVENT_FINISHED = 1,  /**< Debuging session has finished */
+	UDEBUG_EVENT_STOP,          /**< Stopped on DEBUG_STOP request */
+	UDEBUG_EVENT_SYSCALL_B,     /**< Before beginning syscall execution */
+	UDEBUG_EVENT_SYSCALL_E,     /**< After finishing syscall execution */
+	UDEBUG_EVENT_THREAD_B,      /**< The task created a new thread */
+	UDEBUG_EVENT_THREAD_E       /**< A thread exited */
+} udebug_event_t;
+
+typedef enum {
+	UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
+	UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
+	UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
+	UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
+	UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
+	UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
+	UDEBUG_EM_ALL =
+	    (UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
+	    UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
+	    UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
+	    UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
+	    UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
+	    UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E))
+} udebug_evmask_t;
+
+#ifdef KERNEL
+
 #include <ipc/ipc.h>
-
-typedef enum { /* udebug_method_t */
-
-/** Start debugging the recipient.
- * Causes all threads in the receiving task to stop. When they
- * are all stoped, an answer with retval 0 is generated.
- */
-UDEBUG_M_BEGIN = 1,
-
-/** Finish debugging the recipient.
- * Answers all pending GO and GUARD messages.
- */
-UDEBUG_M_END,
-
-/** Set which events should be captured.
- */
-UDEBUG_M_SET_EVMASK,
-
-/** Make sure the debugged task is still there.
- * This message is answered when the debugged task dies
- * or the debugging session ends.
- */
-UDEBUG_M_GUARD,
-
-/** Run a thread until a debugging event occurs.
- * This message is answered when the thread stops
- * in a debugging event.
- *
- * - ARG2 - id of the thread to run
- */
-UDEBUG_M_GO,
-
-/** Stop a thread being debugged.
- * Creates a special STOP event in the thread, causing
- * it to answer a pending GO message (if any).
- */
-UDEBUG_M_STOP,
-
-/** Read arguments of a syscall.
- *
- * - ARG2 - thread identification
- * - ARG3 - destination address in the caller's address space
- *
- */
-UDEBUG_M_ARGS_READ,
-
-/** Read thread's userspace register state (istate_t).
- *
- * - ARG2 - thread identification
- * - ARG3 - destination address in the caller's address space
- *
- * or, on error, retval will be
- * - ENOENT - thread does not exist
- * - EBUSY - register state not available
- */
-UDEBUG_M_REGS_READ,
-
-/** Read the list of the debugged tasks's threads.
- *
- * - ARG2 - destination address in the caller's address space
- * - ARG3 - size of receiving buffer in bytes
- *
- * The kernel fills the buffer with a series of sysarg_t values
- * (thread ids). On answer, the kernel will set:
- *
- * - ARG2 - number of bytes that were actually copied
- * - ARG3 - number of bytes of the complete data
- *
- */
-UDEBUG_M_THREAD_READ,
-
-/** Read the name of the debugged task.
- *
- * - ARG2 - destination address in the caller's address space
- * - ARG3 - size of receiving buffer in bytes
- *
- * The kernel fills the buffer with a non-terminated string.
- *
- * - ARG2 - number of bytes that were actually copied
- * - ARG3 - number of bytes of the complete data
- *
- */
-UDEBUG_M_NAME_READ,
-
-/** Read the list of the debugged task's address space areas.
- *
- * - ARG2 - destination address in the caller's address space
- * - ARG3 - size of receiving buffer in bytes
- *
- * The kernel fills the buffer with a series of as_area_info_t structures.
- * Upon answer, the kernel will set:
- *
- * - ARG2 - number of bytes that were actually copied
- * - ARG3 - number of bytes of the complete data
- *
- */
-UDEBUG_M_AREAS_READ,
-
-/** Read the debugged tasks's memory.
- *
- * - ARG2 - destination address in the caller's address space
- * - ARG3 - source address in the recipient's address space
- * - ARG4 - size of receiving buffer in bytes
- *
- */
-UDEBUG_M_MEM_READ,
-
-} udebug_method_t;
-
-
-typedef enum {
-	UDEBUG_EVENT_FINISHED = 1,	/**< Debuging session has finished */
-	UDEBUG_EVENT_STOP,		/**< Stopped on DEBUG_STOP request */
-	UDEBUG_EVENT_SYSCALL_B,		/**< Before beginning syscall execution */
-	UDEBUG_EVENT_SYSCALL_E,		/**< After finishing syscall execution */
-	UDEBUG_EVENT_THREAD_B,		/**< The task created a new thread */
-	UDEBUG_EVENT_THREAD_E		/**< A thread exited */
-} udebug_event_t;
-
-#define UDEBUG_EVMASK(event) (1 << ((event) - 1))
-
-typedef enum {
-	UDEBUG_EM_FINISHED	= UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
-	UDEBUG_EM_STOP		= UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
-	UDEBUG_EM_SYSCALL_B	= UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
-	UDEBUG_EM_SYSCALL_E	= UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
-	UDEBUG_EM_THREAD_B	= UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
-	UDEBUG_EM_THREAD_E	= UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
-	UDEBUG_EM_ALL		=
-		UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
-		UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
-		UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
-		UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
-		UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
-		UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E)
-} udebug_evmask_t;
-
-#ifdef KERNEL
-
 #include <synch/mutex.h>
 #include <synch/condvar.h>
@@ -196,5 +202,5 @@
 	mutex_t lock;
 	char *lock_owner;
-
+	
 	udebug_task_state_t dt_state;
 	call_t *begin_call;
@@ -209,15 +215,15 @@
 	/** Synchronize debug ops on this thread / access to this structure. */
 	mutex_t lock;
-
+	
 	waitq_t go_wq;
 	call_t *go_call;
 	sysarg_t syscall_args[6];
 	istate_t *uspace_state;
-
+	
 	/** What type of event are we stopped in or 0 if none. */
 	udebug_event_t cur_event;
-	bool go;		/**< thread is GO */
-	bool stoppable;		/**< thread is stoppable */
-	bool active;		/**< thread is in a debugging session */
+	bool go;         /**< Thread is GO */
+	bool stoppable;  /**< Thread is stoppable */
+	bool active;     /**< Thread is in a debugging session */
 	condvar_t active_cv;
 } udebug_thread_t;
@@ -226,12 +232,11 @@
 struct thread;
 
-void udebug_task_init(udebug_task_t *ut);
-void udebug_thread_initialize(udebug_thread_t *ut);
-
-void udebug_syscall_event(sysarg_t a1, sysarg_t a2, sysarg_t a3,
-    sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id, sysarg_t rc,
-    bool end_variant);
-
-void udebug_thread_b_event_attach(struct thread *t, struct task *ta);
+void udebug_task_init(udebug_task_t *);
+void udebug_thread_initialize(udebug_thread_t *);
+
+void udebug_syscall_event(sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, bool);
+
+void udebug_thread_b_event_attach(struct thread *, struct task *);
 void udebug_thread_e_event(void);
 
@@ -241,5 +246,5 @@
 void udebug_before_thread_runs(void);
 
-int udebug_task_cleanup(struct task *ta);
+int udebug_task_cleanup(struct task *);
 void udebug_thread_fault(void);
 
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/console/cmd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -553,6 +553,11 @@
 	for (i = 0; basic_commands[i]; i++) {
 		cmd_initialize(basic_commands[i]);
-		if (!cmd_register(basic_commands[i]))
-			printf("Cannot register command %s\n", basic_commands[i]->name);
+	}
+
+	for (i = 0; basic_commands[i]; i++) {
+		if (!cmd_register(basic_commands[i])) {
+			printf("Cannot register command %s\n",
+			    basic_commands[i]->name);
+		}
 	}
 }
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/console/console.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -160,4 +160,5 @@
 	klog_parea.pbase = (uintptr_t) faddr;
 	klog_parea.frames = SIZE2FRAMES(sizeof(klog));
+	klog_parea.unpriv = false;
 	ddi_parea_register(&klog_parea);
 	
Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/ddi/ddi.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -104,13 +104,17 @@
 {
 	ASSERT(TASK);
-	ASSERT((pf % FRAME_SIZE) == 0);
-	ASSERT((vp % PAGE_SIZE) == 0);
-	
-	/*
-	 * Make sure the caller is authorised to make this syscall.
-	 */
-	cap_t caps = cap_get(TASK);
-	if (!(caps & CAP_MEM_MANAGER))
-		return EPERM;
+	
+	if ((pf % FRAME_SIZE) != 0)
+		return EBADMEM;
+	
+	if ((vp % PAGE_SIZE) != 0)
+		return EBADMEM;
+	
+	/*
+	 * Unprivileged tasks are only allowed to map pareas
+	 * which are explicitly marked as such.
+	 */
+	bool priv =
+	    ((cap_get(TASK) & CAP_MEM_MANAGER) == CAP_MEM_MANAGER);
 	
 	mem_backend_data_t backend_data;
@@ -123,14 +127,27 @@
 	
 	if (znum == (size_t) -1) {
-		/* Frames not found in any zones
-		 * -> assume it is hardware device and allow mapping
+		/*
+		 * Frames not found in any zone
+		 * -> assume it is a hardware device and allow mapping
+		 *    for privileged tasks.
 		 */
 		irq_spinlock_unlock(&zones.lock, true);
+		
+		if (!priv)
+			return EPERM;
+		
 		goto map;
 	}
 	
 	if (zones.info[znum].flags & ZONE_FIRMWARE) {
-		/* Frames are part of firmware */
+		/*
+		 * Frames are part of firmware
+		 * -> allow mapping for privileged tasks.
+		 */
 		irq_spinlock_unlock(&zones.lock, true);
+		
+		if (!priv)
+			return EPERM;
+		
 		goto map;
 	}
@@ -138,6 +155,6 @@
 	if (zone_flags_available(zones.info[znum].flags)) {
 		/*
-		 * Frames are part of physical memory, check if the memory
-		 * region is enabled for mapping.
+		 * Frames are part of physical memory, check
+		 * if the memory region is enabled for mapping.
 		 */
 		irq_spinlock_unlock(&zones.lock, true);
@@ -150,5 +167,12 @@
 		if ((!parea) || (parea->frames < pages)) {
 			mutex_unlock(&parea_lock);
-			goto err;
+			return ENOENT;
+		}
+		
+		if (!priv) {
+			if (!parea->unpriv) {
+				mutex_unlock(&parea_lock);
+				return EPERM;
+			}
 		}
 		
@@ -158,6 +182,4 @@
 	
 	irq_spinlock_unlock(&zones.lock, true);
-	
-err:
 	return ENOENT;
 	
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/interrupt/interrupt.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,5 +45,4 @@
 #include <console/console.h>
 #include <console/cmd.h>
-#include <ipc/event.h>
 #include <synch/mutex.h>
 #include <time/delay.h>
@@ -188,23 +187,5 @@
 	printf("\n");
 	
-	/*
-	 * Userspace can subscribe for FAULT events to take action
-	 * whenever a thread faults. (E.g. take a dump, run a debugger).
-	 * The notification is always available, but unless Udebug is enabled,
-	 * that's all you get.
-	 */
-	if (event_is_subscribed(EVENT_FAULT)) {
-		/* Notify the subscriber that a fault occurred. */
-		event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
-		    UPPER32(TASK->taskid), (sysarg_t) THREAD);
-		
-#ifdef CONFIG_UDEBUG
-		/* Wait for a debugging session. */
-		udebug_thread_fault();
-#endif
-	}
-	
-	task_kill(TASK->taskid);
-	thread_exit();
+	task_kill_self(true);
 }
 
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/ipc/ipc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -787,5 +787,5 @@
 	}
 	
-	printf(" --- outgoing answers ---\n");
+	printf(" --- incoming answers ---\n");
 	for (cur = task->answerbox.answers.next;
 	    cur != &task->answerbox.answers;
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/ipc/irq.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,5 +42,5 @@
  *
  * The structure of a notification message is as follows:
- * - IMETHOD: interface and method as registered by the SYS_IPC_REGISTER_IRQ
+ * - IMETHOD: interface and method as registered by the SYS_REGISTER_IRQ
  *            syscall
  * - ARG1: payload modified by a 'top-half' handler
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/ipc/sysipc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -1105,5 +1105,5 @@
  *
  */
-sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t imethod,
+sysarg_t sys_register_irq(inr_t inr, devno_t devno, sysarg_t imethod,
     irq_code_t *ucode)
 {
@@ -1122,5 +1122,5 @@
  *
  */
-sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)
+sysarg_t sys_unregister_irq(inr_t inr, devno_t devno)
 {
 	if (!(cap_get(TASK) & CAP_IRQ_REG))
Index: kernel/generic/src/lib/elf.c
===================================================================
--- kernel/generic/src/lib/elf.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/lib/elf.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -157,4 +157,5 @@
 	case PT_NULL:
 	case PT_PHDR:
+	case PT_NOTE:
 		break;
 	case PT_LOAD:
@@ -173,5 +174,4 @@
 		break;
 	case PT_SHLIB:
-	case PT_NOTE:
 	case PT_LOPROC:
 	case PT_HIPROC:
Index: kernel/generic/src/lib/rd.c
===================================================================
--- kernel/generic/src/lib/rd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/lib/rd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -90,4 +90,5 @@
 	    FRAME_SIZE);
 	rd_parea.frames = SIZE2FRAMES(dsize);
+	rd_parea.unpriv = false;
 	ddi_parea_register(&rd_parea);
 
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/mm/as.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -71,4 +71,5 @@
 #include <memstr.h>
 #include <macros.h>
+#include <bitops.h>
 #include <arch.h>
 #include <errno.h>
@@ -86,17 +87,15 @@
  * Each architecture decides what functions will be used to carry out
  * address space operations such as creating or locking page tables.
- *
  */
 as_operations_t *as_operations = NULL;
 
-/**
- * Slab for as_t objects.
+/** Slab for as_t objects.
  *
  */
 static slab_cache_t *as_slab;
 
-/**
- * This lock serializes access to the ASID subsystem.
- * It protects:
+/** ASID subsystem lock.
+ *
+ * This lock protects:
  * - inactive_as_with_asid_head list
  * - as->asid for each as of the as_t type
@@ -107,7 +106,6 @@
 
 /**
- * This list contains address spaces that are not active on any
- * processor and that have valid ASID.
- *
+ * Inactive address spaces (on all processors)
+ * that have valid ASID.
  */
 LIST_INITIALIZE(inactive_as_with_asid_head);
@@ -123,13 +121,10 @@
 	mutex_initialize(&as->lock, MUTEX_PASSIVE);
 	
-	int rc = as_constructor_arch(as, flags);
-	
-	return rc;
+	return as_constructor_arch(as, flags);
 }
 
 NO_TRACE static size_t as_destructor(void *obj)
 {
-	as_t *as = (as_t *) obj;
-	return as_destructor_arch(as);
+	return as_destructor_arch((as_t *) obj);
 }
 
@@ -146,5 +141,6 @@
 		panic("Cannot create kernel address space.");
 	
-	/* Make sure the kernel address space
+	/*
+	 * Make sure the kernel address space
 	 * reference count never drops to zero.
 	 */
@@ -195,5 +191,5 @@
 {
 	DEADLOCK_PROBE_INIT(p_asidlock);
-
+	
 	ASSERT(as != AS);
 	ASSERT(atomic_get(&as->refcount) == 0);
@@ -203,5 +199,5 @@
 	 * lock its mutex.
 	 */
-
+	
 	/*
 	 * We need to avoid deadlock between TLB shootdown and asidlock.
@@ -210,5 +206,4 @@
 	 * disabled to prevent nested context switches. We also depend on the
 	 * fact that so far no spinlocks are held.
-	 *
 	 */
 	preemption_disable();
@@ -235,5 +230,5 @@
 	spinlock_unlock(&asidlock);
 	interrupts_restore(ipl);
-
+	
 	
 	/*
@@ -241,5 +236,4 @@
 	 * The B+tree must be walked carefully because it is
 	 * also being destroyed.
-	 *
 	 */
 	bool cond = true;
@@ -268,6 +262,6 @@
 /** Hold a reference to an address space.
  *
- * Holding a reference to an address space prevents destruction of that address
- * space.
+ * Holding a reference to an address space prevents destruction
+ * of that address space.
  *
  * @param as Address space to be held.
@@ -281,6 +275,6 @@
 /** Release a reference to an address space.
  *
- * The last one to release a reference to an address space destroys the address
- * space.
+ * The last one to release a reference to an address space
+ * destroys the address space.
  *
  * @param asAddress space to be released.
@@ -295,22 +289,22 @@
 /** Check area conflicts with other areas.
  *
- * @param as         Address space.
- * @param va         Starting virtual address of the area being tested.
- * @param size       Size of the area being tested.
- * @param avoid_area Do not touch this area.
+ * @param as    Address space.
+ * @param addr  Starting virtual address of the area being tested.
+ * @param count Number of pages in the area being tested.
+ * @param avoid Do not touch this area.
  *
  * @return True if there is no conflict, false otherwise.
  *
  */
-NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
-    as_area_t *avoid_area)
-{
+NO_TRACE static bool check_area_conflicts(as_t *as, uintptr_t addr,
+    size_t count, as_area_t *avoid)
+{
+	ASSERT((addr % PAGE_SIZE) == 0);
 	ASSERT(mutex_locked(&as->lock));
 	
 	/*
 	 * We don't want any area to have conflicts with NULL page.
-	 *
-	 */
-	if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE))
+	 */
+	if (overlaps(addr, count << PAGE_WIDTH, (uintptr_t) NULL, PAGE_SIZE))
 		return false;
 	
@@ -321,11 +315,10 @@
 	 * record in the left neighbour, the leftmost record in the right
 	 * neighbour and all records in the leaf node itself.
-	 *
 	 */
 	btree_node_t *leaf;
 	as_area_t *area =
-	    (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
+	    (as_area_t *) btree_search(&as->as_area_btree, addr, &leaf);
 	if (area) {
-		if (area != avoid_area)
+		if (area != avoid)
 			return false;
 	}
@@ -337,12 +330,15 @@
 		area = (as_area_t *) node->value[node->keys - 1];
 		
-		mutex_lock(&area->lock);
-		
-		if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
+		if (area != avoid) {
+			mutex_lock(&area->lock);
+			
+			if (overlaps(addr, count << PAGE_WIDTH,
+			    area->base, area->pages << PAGE_WIDTH)) {
+				mutex_unlock(&area->lock);
+				return false;
+			}
+			
 			mutex_unlock(&area->lock);
-			return false;
-		}
-		
-		mutex_unlock(&area->lock);
+		}
 	}
 	
@@ -351,12 +347,15 @@
 		area = (as_area_t *) node->value[0];
 		
-		mutex_lock(&area->lock);
-		
-		if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
+		if (area != avoid) {
+			mutex_lock(&area->lock);
+			
+			if (overlaps(addr, count << PAGE_WIDTH,
+			    area->base, area->pages << PAGE_WIDTH)) {
+				mutex_unlock(&area->lock);
+				return false;
+			}
+			
 			mutex_unlock(&area->lock);
-			return false;
-		}
-		
-		mutex_unlock(&area->lock);
+		}
 	}
 	
@@ -366,10 +365,11 @@
 		area = (as_area_t *) leaf->value[i];
 		
-		if (area == avoid_area)
+		if (area == avoid)
 			continue;
 		
 		mutex_lock(&area->lock);
 		
-		if (overlaps(va, size, area->base, area->pages * PAGE_SIZE)) {
+		if (overlaps(addr, count << PAGE_WIDTH,
+		    area->base, area->pages << PAGE_WIDTH)) {
 			mutex_unlock(&area->lock);
 			return false;
@@ -382,8 +382,7 @@
 	 * So far, the area does not conflict with other areas.
 	 * Check if it doesn't conflict with kernel address space.
-	 *
 	 */
 	if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
-		return !overlaps(va, size,
+		return !overlaps(addr, count << PAGE_WIDTH,
 		    KERNEL_ADDRESS_SPACE_START,
 		    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
@@ -412,9 +411,11 @@
     mem_backend_data_t *backend_data)
 {
-	if (base % PAGE_SIZE)
+	if ((base % PAGE_SIZE) != 0)
 		return NULL;
 	
-	if (!size)
+	if (size == 0)
 		return NULL;
+	
+	size_t pages = SIZE2FRAMES(size);
 	
 	/* Writeable executable areas are not supported. */
@@ -424,5 +425,5 @@
 	mutex_lock(&as->lock);
 	
-	if (!check_area_conflicts(as, base, size, NULL)) {
+	if (!check_area_conflicts(as, base, pages, NULL)) {
 		mutex_unlock(&as->lock);
 		return NULL;
@@ -436,5 +437,6 @@
 	area->flags = flags;
 	area->attributes = attrs;
-	area->pages = SIZE2FRAMES(size);
+	area->pages = pages;
+	area->resident = 0;
 	area->base = base;
 	area->sh_info = NULL;
@@ -479,5 +481,4 @@
 	 * to find out whether this is a miss or va belongs to an address
 	 * space area found there.
-	 *
 	 */
 	
@@ -490,5 +491,6 @@
 		mutex_lock(&area->lock);
 		
-		if ((area->base <= va) && (va < area->base + area->pages * PAGE_SIZE))
+		if ((area->base <= va) &&
+		    (va < area->base + (area->pages << PAGE_WIDTH)))
 			return area;
 		
@@ -499,5 +501,4 @@
 	 * Second, locate the left neighbour and test its last record.
 	 * Because of its position in the B+tree, it must have base < va.
-	 *
 	 */
 	btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf);
@@ -507,5 +508,5 @@
 		mutex_lock(&area->lock);
 		
-		if (va < area->base + area->pages * PAGE_SIZE)
+		if (va < area->base + (area->pages << PAGE_WIDTH))
 			return area;
 		
@@ -534,5 +535,4 @@
 	/*
 	 * Locate the area.
-	 *
 	 */
 	as_area_t *area = find_area_and_lock(as, address);
@@ -546,5 +546,4 @@
 		 * Remapping of address space areas associated
 		 * with memory mapped devices is not supported.
-		 *
 		 */
 		mutex_unlock(&area->lock);
@@ -557,5 +556,4 @@
 		 * Remapping of shared address space areas
 		 * is not supported.
-		 *
 		 */
 		mutex_unlock(&area->lock);
@@ -568,5 +566,4 @@
 		/*
 		 * Zero size address space areas are not allowed.
-		 *
 		 */
 		mutex_unlock(&area->lock);
@@ -576,10 +573,9 @@
 	
 	if (pages < area->pages) {
-		uintptr_t start_free = area->base + pages * PAGE_SIZE;
+		uintptr_t start_free = area->base + (pages << PAGE_WIDTH);
 		
 		/*
 		 * Shrinking the area.
 		 * No need to check for overlaps.
-		 *
 		 */
 		
@@ -588,8 +584,7 @@
 		/*
 		 * Start TLB shootdown sequence.
-		 *
 		 */
 		ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid,
-		    area->base + pages * PAGE_SIZE, area->pages - pages);
+		    area->base + (pages << PAGE_WIDTH), area->pages - pages);
 		
 		/*
@@ -599,5 +594,4 @@
 		 * is also the right way to remove part of the used_space
 		 * B+tree leaf list.
-		 *
 		 */
 		bool cond = true;
@@ -615,13 +609,12 @@
 				size_t i = 0;
 				
-				if (overlaps(ptr, size * PAGE_SIZE, area->base,
-				    pages * PAGE_SIZE)) {
+				if (overlaps(ptr, size << PAGE_WIDTH, area->base,
+				    pages << PAGE_WIDTH)) {
 					
-					if (ptr + size * PAGE_SIZE <= start_free) {
+					if (ptr + (size << PAGE_WIDTH) <= start_free) {
 						/*
 						 * The whole interval fits
 						 * completely in the resized
 						 * address space area.
-						 *
 						 */
 						break;
@@ -632,5 +625,4 @@
 					 * to b and c overlaps with the resized
 					 * address space area.
-					 *
 					 */
 					
@@ -652,5 +644,5 @@
 				for (; i < size; i++) {
 					pte_t *pte = page_mapping_find(as, ptr +
-					    i * PAGE_SIZE);
+					    (i << PAGE_WIDTH));
 					
 					ASSERT(pte);
@@ -661,10 +653,10 @@
 					    (area->backend->frame_free)) {
 						area->backend->frame_free(area,
-						    ptr + i * PAGE_SIZE,
+						    ptr + (i << PAGE_WIDTH),
 						    PTE_GET_FRAME(pte));
 					}
 					
 					page_mapping_remove(as, ptr +
-					    i * PAGE_SIZE);
+					    (i << PAGE_WIDTH));
 				}
 			}
@@ -673,16 +665,14 @@
 		/*
 		 * Finish TLB shootdown sequence.
-		 *
-		 */
-		
-		tlb_invalidate_pages(as->asid, area->base + pages * PAGE_SIZE,
+		 */
+		
+		tlb_invalidate_pages(as->asid, area->base + (pages << PAGE_WIDTH),
 		    area->pages - pages);
 		
 		/*
 		 * Invalidate software translation caches (e.g. TSB on sparc64).
-		 *
 		 */
 		as_invalidate_translation_cache(as, area->base +
-		    pages * PAGE_SIZE, area->pages - pages);
+		    (pages << PAGE_WIDTH), area->pages - pages);
 		tlb_shootdown_finalize(ipl);
 		
@@ -692,8 +682,6 @@
 		 * Growing the area.
 		 * Check for overlaps with other address space areas.
-		 *
-		 */
-		if (!check_area_conflicts(as, address, pages * PAGE_SIZE,
-		    area)) {
+		 */
+		if (!check_area_conflicts(as, address, pages, area)) {
 			mutex_unlock(&area->lock);
 			mutex_unlock(&as->lock);
@@ -794,5 +782,6 @@
 			
 			for (size = 0; size < (size_t) node->value[i]; size++) {
-				pte_t *pte = page_mapping_find(as, ptr + size * PAGE_SIZE);
+				pte_t *pte =
+				    page_mapping_find(as, ptr + (size << PAGE_WIDTH));
 				
 				ASSERT(pte);
@@ -803,8 +792,8 @@
 				    (area->backend->frame_free)) {
 					area->backend->frame_free(area,
-					    ptr + size * PAGE_SIZE, PTE_GET_FRAME(pte));
+					    ptr + (size << PAGE_WIDTH), PTE_GET_FRAME(pte));
 				}
 				
-				page_mapping_remove(as, ptr + size * PAGE_SIZE);
+				page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
 			}
 		}
@@ -813,5 +802,4 @@
 	/*
 	 * Finish TLB shootdown sequence.
-	 *
 	 */
 	
@@ -821,5 +809,4 @@
 	 * Invalidate potential software translation caches (e.g. TSB on
 	 * sparc64).
-	 *
 	 */
 	as_invalidate_translation_cache(as, area->base, area->pages);
@@ -839,5 +826,4 @@
 	/*
 	 * Remove the empty area from address space.
-	 *
 	 */
 	btree_remove(&as->as_area_btree, base, NULL);
@@ -881,5 +867,4 @@
 		/*
 		 * Could not find the source address space area.
-		 *
 		 */
 		mutex_unlock(&src_as->lock);
@@ -891,5 +876,4 @@
 		 * There is no backend or the backend does not
 		 * know how to share the area.
-		 *
 		 */
 		mutex_unlock(&src_area->lock);
@@ -898,5 +882,5 @@
 	}
 	
-	size_t src_size = src_area->pages * PAGE_SIZE;
+	size_t src_size = src_area->pages << PAGE_WIDTH;
 	unsigned int src_flags = src_area->flags;
 	mem_backend_t *src_backend = src_area->backend;
@@ -918,5 +902,4 @@
 	 * First, prepare the area for sharing.
 	 * Then it will be safe to unlock it.
-	 *
 	 */
 	share_info_t *sh_info = src_area->sh_info;
@@ -930,5 +913,4 @@
 		/*
 		 * Call the backend to setup sharing.
-		 *
 		 */
 		src_area->backend->share(src_area);
@@ -949,5 +931,4 @@
 	 * The flags of the source area are masked against dst_flags_mask
 	 * to support sharing in less privileged mode.
-	 *
 	 */
 	as_area_t *dst_area = as_area_create(dst_as, dst_flags_mask, src_size,
@@ -966,5 +947,4 @@
 	 * fully initialized. Clear the AS_AREA_ATTR_PARTIAL
 	 * attribute and set the sh_info.
-	 *
 	 */
 	mutex_lock(&dst_as->lock);
@@ -989,4 +969,6 @@
 NO_TRACE bool as_area_check_access(as_area_t *area, pf_access_t access)
 {
+	ASSERT(mutex_locked(&area->lock));
+	
 	int flagmap[] = {
 		[PF_ACCESS_READ] = AS_AREA_READ,
@@ -994,6 +976,4 @@
 		[PF_ACCESS_EXEC] = AS_AREA_EXEC
 	};
-
-	ASSERT(mutex_locked(&area->lock));
 	
 	if (!(area->flags & flagmap[access]))
@@ -1066,5 +1046,4 @@
 	/*
 	 * Compute total number of used pages in the used_space B+tree
-	 *
 	 */
 	size_t used_pages = 0;
@@ -1088,5 +1067,4 @@
 	/*
 	 * Start TLB shootdown sequence.
-	 *
 	 */
 	ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid, area->base,
@@ -1096,5 +1074,4 @@
 	 * Remove used pages from page tables and remember their frame
 	 * numbers.
-	 *
 	 */
 	size_t frame_idx = 0;
@@ -1111,5 +1088,6 @@
 			
 			for (size = 0; size < (size_t) node->value[i]; size++) {
-				pte_t *pte = page_mapping_find(as, ptr + size * PAGE_SIZE);
+				pte_t *pte =
+				    page_mapping_find(as, ptr + (size << PAGE_WIDTH));
 				
 				ASSERT(pte);
@@ -1120,5 +1098,5 @@
 				
 				/* Remove old mapping */
-				page_mapping_remove(as, ptr + size * PAGE_SIZE);
+				page_mapping_remove(as, ptr + (size << PAGE_WIDTH));
 			}
 		}
@@ -1127,5 +1105,4 @@
 	/*
 	 * Finish TLB shootdown sequence.
-	 *
 	 */
 	
@@ -1135,5 +1112,4 @@
 	 * Invalidate potential software translation caches (e.g. TSB on
 	 * sparc64).
-	 *
 	 */
 	as_invalidate_translation_cache(as, area->base, area->pages);
@@ -1168,5 +1144,5 @@
 				
 				/* Insert the new mapping */
-				page_mapping_insert(as, ptr + size * PAGE_SIZE,
+				page_mapping_insert(as, ptr + (size << PAGE_WIDTH),
 				    old_frame[frame_idx++], page_flags);
 				
@@ -1217,5 +1193,4 @@
 		 * No area contained mapping for 'page'.
 		 * Signal page fault to low-level handler.
-		 *
 		 */
 		mutex_unlock(&AS->lock);
@@ -1237,5 +1212,4 @@
 		 * The address space area is not backed by any backend
 		 * or the backend cannot handle page faults.
-		 *
 		 */
 		mutex_unlock(&area->lock);
@@ -1249,5 +1223,4 @@
 	 * To avoid race condition between two page faults on the same address,
 	 * we need to make sure the mapping has not been already inserted.
-	 *
 	 */
 	pte_t *pte;
@@ -1267,5 +1240,4 @@
 	/*
 	 * Resort to the backend page fault handler.
-	 *
 	 */
 	if (area->backend->page_fault(area, page, access) != AS_PF_OK) {
@@ -1322,5 +1294,4 @@
 		 * preemption is disabled. We should not be
 		 * holding any other lock.
-		 *
 		 */
 		(void) interrupts_enable();
@@ -1342,5 +1313,4 @@
 			 * list of inactive address spaces with assigned
 			 * ASID.
-			 *
 			 */
 			ASSERT(old_as->asid != ASID_INVALID);
@@ -1353,5 +1323,4 @@
 		 * Perform architecture-specific tasks when the address space
 		 * is being removed from the CPU.
-		 *
 		 */
 		as_deinstall_arch(old_as);
@@ -1360,5 +1329,4 @@
 	/*
 	 * Second, prepare the new address space.
-	 *
 	 */
 	if ((new_as->cpu_refcount++ == 0) && (new_as != AS_KERNEL)) {
@@ -1376,5 +1344,4 @@
 	 * Perform architecture-specific steps.
 	 * (e.g. write ASID to hardware register etc.)
-	 *
 	 */
 	as_install_arch(new_as);
@@ -1395,5 +1362,5 @@
 {
 	ASSERT(mutex_locked(&area->lock));
-
+	
 	return area_flags_to_page_flags(area->flags);
 }
@@ -1499,5 +1466,5 @@
 	
 	if (src_area) {
-		size = src_area->pages * PAGE_SIZE;
+		size = src_area->pages << PAGE_WIDTH;
 		mutex_unlock(&src_area->lock);
 	} else
@@ -1516,8 +1483,8 @@
  * @param count Number of page to be marked.
  *
- * @return Zero on failure and non-zero on success.
- *
- */
-int used_space_insert(as_area_t *area, uintptr_t page, size_t count)
+ * @return False on failure or true on success.
+ *
+ */
+bool used_space_insert(as_area_t *area, uintptr_t page, size_t count)
 {
 	ASSERT(mutex_locked(&area->lock));
@@ -1530,12 +1497,11 @@
 		/*
 		 * We hit the beginning of some used space.
-		 *
-		 */
-		return 0;
+		 */
+		return false;
 	}
 	
 	if (!leaf->keys) {
 		btree_insert(&area->used_space, page, (void *) count, leaf);
-		return 1;
+		goto success;
 	}
 	
@@ -1551,54 +1517,49 @@
 		 * somewhere between the rightmost interval of
 		 * the left neigbour and the first interval of the leaf.
-		 *
 		 */
 		
 		if (page >= right_pg) {
 			/* Do nothing. */
-		} else if (overlaps(page, count * PAGE_SIZE, left_pg,
-		    left_cnt * PAGE_SIZE)) {
+		} else if (overlaps(page, count << PAGE_WIDTH, left_pg,
+		    left_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the left interval. */
-			return 0;
-		} else if (overlaps(page, count * PAGE_SIZE, right_pg,
-		    right_cnt * PAGE_SIZE)) {
+			return false;
+		} else if (overlaps(page, count << PAGE_WIDTH, right_pg,
+		    right_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the right interval. */
-			return 0;
-		} else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
-		    (page + count * PAGE_SIZE == right_pg)) {
+			return false;
+		} else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
+		    (page + (count << PAGE_WIDTH) == right_pg)) {
 			/*
 			 * The interval can be added by merging the two already
 			 * present intervals.
-			 *
 			 */
 			node->value[node->keys - 1] += count + right_cnt;
 			btree_remove(&area->used_space, right_pg, leaf);
-			return 1;
-		} else if (page == left_pg + left_cnt * PAGE_SIZE) {
+			goto success;
+		} else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
 			/*
 			 * The interval can be added by simply growing the left
 			 * interval.
-			 *
 			 */
 			node->value[node->keys - 1] += count;
-			return 1;
-		} else if (page + count * PAGE_SIZE == right_pg) {
+			goto success;
+		} else if (page + (count << PAGE_WIDTH) == right_pg) {
 			/*
 			 * The interval can be addded by simply moving base of
 			 * the right interval down and increasing its size
 			 * accordingly.
-			 *
 			 */
 			leaf->value[0] += count;
 			leaf->key[0] = page;
-			return 1;
+			goto success;
 		} else {
 			/*
 			 * The interval is between both neigbouring intervals,
 			 * but cannot be merged with any of them.
-			 *
 			 */
 			btree_insert(&area->used_space, page, (void *) count,
 			    leaf);
-			return 1;
+			goto success;
 		}
 	} else if (page < leaf->key[0]) {
@@ -1609,30 +1570,27 @@
 		 * Investigate the border case in which the left neighbour does
 		 * not exist but the interval fits from the left.
-		 *
-		 */
-		
-		if (overlaps(page, count * PAGE_SIZE, right_pg,
-		    right_cnt * PAGE_SIZE)) {
+		 */
+		
+		if (overlaps(page, count << PAGE_WIDTH, right_pg,
+		    right_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the right interval. */
-			return 0;
-		} else if (page + count * PAGE_SIZE == right_pg) {
+			return false;
+		} else if (page + (count << PAGE_WIDTH) == right_pg) {
 			/*
 			 * The interval can be added by moving the base of the
 			 * right interval down and increasing its size
 			 * accordingly.
-			 *
 			 */
 			leaf->key[0] = page;
 			leaf->value[0] += count;
-			return 1;
+			goto success;
 		} else {
 			/*
 			 * The interval doesn't adjoin with the right interval.
 			 * It must be added individually.
-			 *
 			 */
 			btree_insert(&area->used_space, page, (void *) count,
 			    leaf);
-			return 1;
+			goto success;
 		}
 	}
@@ -1649,54 +1607,49 @@
 		 * somewhere between the leftmost interval of
 		 * the right neigbour and the last interval of the leaf.
-		 *
 		 */
 		
 		if (page < left_pg) {
 			/* Do nothing. */
-		} else if (overlaps(page, count * PAGE_SIZE, left_pg,
-		    left_cnt * PAGE_SIZE)) {
+		} else if (overlaps(page, count << PAGE_WIDTH, left_pg,
+		    left_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the left interval. */
-			return 0;
-		} else if (overlaps(page, count * PAGE_SIZE, right_pg,
-		    right_cnt * PAGE_SIZE)) {
+			return false;
+		} else if (overlaps(page, count << PAGE_WIDTH, right_pg,
+		    right_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the right interval. */
-			return 0;
-		} else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
-		    (page + count * PAGE_SIZE == right_pg)) {
+			return false;
+		} else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
+		    (page + (count << PAGE_WIDTH) == right_pg)) {
 			/*
 			 * The interval can be added by merging the two already
 			 * present intervals.
-			 *
 			 */
 			leaf->value[leaf->keys - 1] += count + right_cnt;
 			btree_remove(&area->used_space, right_pg, node);
-			return 1;
-		} else if (page == left_pg + left_cnt * PAGE_SIZE) {
+			goto success;
+		} else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
 			/*
 			 * The interval can be added by simply growing the left
 			 * interval.
-			 *
 			 */
-			leaf->value[leaf->keys - 1] +=  count;
-			return 1;
-		} else if (page + count * PAGE_SIZE == right_pg) {
+			leaf->value[leaf->keys - 1] += count;
+			goto success;
+		} else if (page + (count << PAGE_WIDTH) == right_pg) {
 			/*
 			 * The interval can be addded by simply moving base of
 			 * the right interval down and increasing its size
 			 * accordingly.
-			 *
 			 */
 			node->value[0] += count;
 			node->key[0] = page;
-			return 1;
+			goto success;
 		} else {
 			/*
 			 * The interval is between both neigbouring intervals,
 			 * but cannot be merged with any of them.
-			 *
 			 */
 			btree_insert(&area->used_space, page, (void *) count,
 			    leaf);
-			return 1;
+			goto success;
 		}
 	} else if (page >= leaf->key[leaf->keys - 1]) {
@@ -1707,28 +1660,25 @@
 		 * Investigate the border case in which the right neighbour
 		 * does not exist but the interval fits from the right.
-		 *
-		 */
-		
-		if (overlaps(page, count * PAGE_SIZE, left_pg,
-		    left_cnt * PAGE_SIZE)) {
+		 */
+		
+		if (overlaps(page, count << PAGE_WIDTH, left_pg,
+		    left_cnt << PAGE_WIDTH)) {
 			/* The interval intersects with the left interval. */
-			return 0;
-		} else if (left_pg + left_cnt * PAGE_SIZE == page) {
+			return false;
+		} else if (left_pg + (left_cnt << PAGE_WIDTH) == page) {
 			/*
 			 * The interval can be added by growing the left
 			 * interval.
-			 *
 			 */
 			leaf->value[leaf->keys - 1] += count;
-			return 1;
+			goto success;
 		} else {
 			/*
 			 * The interval doesn't adjoin with the left interval.
 			 * It must be added individually.
-			 *
 			 */
 			btree_insert(&area->used_space, page, (void *) count,
 			    leaf);
-			return 1;
+			goto success;
 		}
 	}
@@ -1738,5 +1688,4 @@
 	 * only between two other intervals of the leaf. The two border cases
 	 * were already resolved.
-	 *
 	 */
 	btree_key_t i;
@@ -1750,51 +1699,45 @@
 			/*
 			 * The interval fits between left_pg and right_pg.
-			 *
 			 */
 			
-			if (overlaps(page, count * PAGE_SIZE, left_pg,
-			    left_cnt * PAGE_SIZE)) {
+			if (overlaps(page, count << PAGE_WIDTH, left_pg,
+			    left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval intersects with the left
 				 * interval.
-				 *
 				 */
-				return 0;
-			} else if (overlaps(page, count * PAGE_SIZE, right_pg,
-			    right_cnt * PAGE_SIZE)) {
+				return false;
+			} else if (overlaps(page, count << PAGE_WIDTH, right_pg,
+			    right_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval intersects with the right
 				 * interval.
-				 *
 				 */
-				return 0;
-			} else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
-			    (page + count * PAGE_SIZE == right_pg)) {
+				return false;
+			} else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) &&
+			    (page + (count << PAGE_WIDTH) == right_pg)) {
 				/*
 				 * The interval can be added by merging the two
 				 * already present intervals.
-				 *
 				 */
 				leaf->value[i - 1] += count + right_cnt;
 				btree_remove(&area->used_space, right_pg, leaf);
-				return 1;
-			} else if (page == left_pg + left_cnt * PAGE_SIZE) {
+				goto success;
+			} else if (page == left_pg + (left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval can be added by simply growing
 				 * the left interval.
-				 *
 				 */
 				leaf->value[i - 1] += count;
-				return 1;
-			} else if (page + count * PAGE_SIZE == right_pg) {
+				goto success;
+			} else if (page + (count << PAGE_WIDTH) == right_pg) {
 				/*
 				 * The interval can be addded by simply moving
 				 * base of the right interval down and
 				 * increasing its size accordingly.
-				 *
 				 */
 				leaf->value[i] += count;
 				leaf->key[i] = page;
-				return 1;
+				goto success;
 			} else {
 				/*
@@ -1802,9 +1745,8 @@
 				 * intervals, but cannot be merged with any of
 				 * them.
-				 *
 				 */
 				btree_insert(&area->used_space, page,
 				    (void *) count, leaf);
-				return 1;
+				goto success;
 			}
 		}
@@ -1813,4 +1755,8 @@
 	panic("Inconsistency detected while adding %zu pages of used "
 	    "space at %p.", count, (void *) page);
+	
+success:
+	area->resident += count;
+	return true;
 }
 
@@ -1823,8 +1769,8 @@
  * @param count Number of page to be marked.
  *
- * @return Zero on failure and non-zero on success.
- *
- */
-int used_space_remove(as_area_t *area, uintptr_t page, size_t count)
+ * @return False on failure or true on success.
+ *
+ */
+bool used_space_remove(as_area_t *area, uintptr_t page, size_t count)
 {
 	ASSERT(mutex_locked(&area->lock));
@@ -1837,25 +1783,24 @@
 		/*
 		 * We are lucky, page is the beginning of some interval.
-		 *
 		 */
 		if (count > pages) {
-			return 0;
+			return false;
 		} else if (count == pages) {
 			btree_remove(&area->used_space, page, leaf);
-			return 1;
+			goto success;
 		} else {
 			/*
 			 * Find the respective interval.
 			 * Decrease its size and relocate its start address.
-			 *
 			 */
 			btree_key_t i;
 			for (i = 0; i < leaf->keys; i++) {
 				if (leaf->key[i] == page) {
-					leaf->key[i] += count * PAGE_SIZE;
+					leaf->key[i] += count << PAGE_WIDTH;
 					leaf->value[i] -= count;
-					return 1;
+					goto success;
 				}
 			}
+			
 			goto error;
 		}
@@ -1867,8 +1812,8 @@
 		size_t left_cnt = (size_t) node->value[node->keys - 1];
 		
-		if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
-		    count * PAGE_SIZE)) {
-			if (page + count * PAGE_SIZE ==
-			    left_pg + left_cnt * PAGE_SIZE) {
+		if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
+		    count << PAGE_WIDTH)) {
+			if (page + (count << PAGE_WIDTH) ==
+			    left_pg + (left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval is contained in the rightmost
@@ -1876,10 +1821,9 @@
 				 * removed by updating the size of the bigger
 				 * interval.
-				 *
 				 */
 				node->value[node->keys - 1] -= count;
-				return 1;
-			} else if (page + count * PAGE_SIZE <
-			    left_pg + left_cnt*PAGE_SIZE) {
+				goto success;
+			} else if (page + (count << PAGE_WIDTH) <
+			    left_pg + (left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval is contained in the rightmost
@@ -1888,17 +1832,17 @@
 				 * the original interval and also inserting a
 				 * new interval.
-				 *
 				 */
-				size_t new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
-				    (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
+				size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
+				    (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
 				node->value[node->keys - 1] -= count + new_cnt;
 				btree_insert(&area->used_space, page +
-				    count * PAGE_SIZE, (void *) new_cnt, leaf);
-				return 1;
+				    (count << PAGE_WIDTH), (void *) new_cnt, leaf);
+				goto success;
 			}
 		}
-		return 0;
+		
+		return false;
 	} else if (page < leaf->key[0])
-		return 0;
+		return false;
 	
 	if (page > leaf->key[leaf->keys - 1]) {
@@ -1906,18 +1850,17 @@
 		size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
 		
-		if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
-		    count * PAGE_SIZE)) {
-			if (page + count * PAGE_SIZE ==
-			    left_pg + left_cnt * PAGE_SIZE) {
+		if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
+		    count << PAGE_WIDTH)) {
+			if (page + (count << PAGE_WIDTH) ==
+			    left_pg + (left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval is contained in the rightmost
 				 * interval of the leaf and can be removed by
 				 * updating the size of the bigger interval.
-				 *
 				 */
 				leaf->value[leaf->keys - 1] -= count;
-				return 1;
-			} else if (page + count * PAGE_SIZE < left_pg +
-			    left_cnt * PAGE_SIZE) {
+				goto success;
+			} else if (page + (count << PAGE_WIDTH) < left_pg +
+			    (left_cnt << PAGE_WIDTH)) {
 				/*
 				 * The interval is contained in the rightmost
@@ -1926,20 +1869,20 @@
 				 * original interval and also inserting a new
 				 * interval.
-				 *
 				 */
-				size_t new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
-				    (page + count * PAGE_SIZE)) >> PAGE_WIDTH;
+				size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) -
+				    (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH;
 				leaf->value[leaf->keys - 1] -= count + new_cnt;
 				btree_insert(&area->used_space, page +
-				    count * PAGE_SIZE, (void *) new_cnt, leaf);
-				return 1;
+				    (count << PAGE_WIDTH), (void *) new_cnt, leaf);
+				goto success;
 			}
 		}
-		return 0;
+		
+		return false;
 	}
 	
 	/*
 	 * The border cases have been already resolved.
-	 * Now the interval can be only between intervals of the leaf. 
+	 * Now the interval can be only between intervals of the leaf.
 	 */
 	btree_key_t i;
@@ -1953,8 +1896,8 @@
 			 * to (i - 1) and i.
 			 */
-			if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
-			    count * PAGE_SIZE)) {
-				if (page + count * PAGE_SIZE ==
-				    left_pg + left_cnt*PAGE_SIZE) {
+			if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page,
+			    count << PAGE_WIDTH)) {
+				if (page + (count << PAGE_WIDTH) ==
+				    left_pg + (left_cnt << PAGE_WIDTH)) {
 					/*
 					 * The interval is contained in the
@@ -1962,10 +1905,9 @@
 					 * be removed by updating the size of
 					 * the bigger interval.
-					 *
 					 */
 					leaf->value[i - 1] -= count;
-					return 1;
-				} else if (page + count * PAGE_SIZE <
-				    left_pg + left_cnt * PAGE_SIZE) {
+					goto success;
+				} else if (page + (count << PAGE_WIDTH) <
+				    left_pg + (left_cnt << PAGE_WIDTH)) {
 					/*
 					 * The interval is contained in the
@@ -1976,15 +1918,16 @@
 					 */
 					size_t new_cnt = ((left_pg +
-					    left_cnt * PAGE_SIZE) -
-					    (page + count * PAGE_SIZE)) >>
+					    (left_cnt << PAGE_WIDTH)) -
+					    (page + (count << PAGE_WIDTH))) >>
 					    PAGE_WIDTH;
 					leaf->value[i - 1] -= count + new_cnt;
 					btree_insert(&area->used_space, page +
-					    count * PAGE_SIZE, (void *) new_cnt,
+					    (count << PAGE_WIDTH), (void *) new_cnt,
 					    leaf);
-					return 1;
+					goto success;
 				}
 			}
-			return 0;
+			
+			return false;
 		}
 	}
@@ -1993,4 +1936,8 @@
 	panic("Inconsistency detected while removing %zu pages of used "
 	    "space from %p.", count, (void *) page);
+	
+success:
+	area->resident -= count;
+	return true;
 }
 
@@ -2027,4 +1974,70 @@
 }
 
+/** Return pointer to unmapped address space area
+ *
+ * @param base Lowest address bound.
+ * @param size Requested size of the allocation.
+ *
+ * @return Pointer to the beginning of unmapped address space area.
+ *
+ */
+sysarg_t sys_as_get_unmapped_area(uintptr_t base, size_t size)
+{
+	if (size == 0)
+		return 0;
+	
+	/*
+	 * Make sure we allocate from page-aligned
+	 * address. Check for possible overflow in
+	 * each step.
+	 */
+	
+	size_t pages = SIZE2FRAMES(size);
+	uintptr_t ret = 0;
+	
+	/*
+	 * Find the lowest unmapped address aligned on the sz
+	 * boundary, not smaller than base and of the required size.
+	 */
+	
+	mutex_lock(&AS->lock);
+	
+	/* First check the base address itself */
+	uintptr_t addr = ALIGN_UP(base, PAGE_SIZE);
+	if ((addr >= base) &&
+	    (check_area_conflicts(AS, addr, pages, NULL)))
+		ret = addr;
+	
+	/* Eventually check the addresses behind each area */
+	link_t *cur;
+	for (cur = AS->as_area_btree.leaf_head.next;
+	    (ret == 0) && (cur != &AS->as_area_btree.leaf_head);
+	    cur = cur->next) {
+		btree_node_t *node =
+		    list_get_instance(cur, btree_node_t, leaf_link);
+		
+		btree_key_t i;
+		for (i = 0; (ret == 0) && (i < node->keys); i++) {
+			as_area_t *area = (as_area_t *) node->value[i];
+			
+			mutex_lock(&area->lock);
+			
+			uintptr_t addr =
+			    ALIGN_UP(area->base + (area->pages << PAGE_WIDTH),
+			    PAGE_SIZE);
+			
+			if ((addr >= base) && (addr >= area->base) &&
+			    (check_area_conflicts(AS, addr, pages, area)))
+				ret = addr;
+			
+			mutex_unlock(&area->lock);
+		}
+	}
+	
+	mutex_unlock(&AS->lock);
+	
+	return (sysarg_t) ret;
+}
+
 /** Get list of adress space areas.
  *
@@ -2093,5 +2106,5 @@
 	mutex_lock(&as->lock);
 	
-	/* print out info about address space areas */
+	/* Print out info about address space areas */
 	link_t *cur;
 	for (cur = as->as_area_btree.leaf_head.next;
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/proc/program.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -171,4 +171,5 @@
 	void *loader = program_loader;
 	if (!loader) {
+		as_destroy(as);
 		printf("Cannot spawn loader as none was registered\n");
 		return ENOENT;
@@ -179,4 +180,5 @@
 	if (rc != EE_OK) {
 		as_destroy(as);
+		printf("Cannot spawn loader (%s)\n", elf_error(rc));
 		return ENOENT;
 	}
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/proc/task.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -384,10 +384,8 @@
 {
 	task_id_t taskid;
-	int rc;
-
-	rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
+	int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
 	if (rc != 0)
 		return (sysarg_t) rc;
-
+	
 	return (sysarg_t) task_kill(taskid);
 }
@@ -520,4 +518,52 @@
 }
 
+/** Kill the currently running task.
+ *
+ * @param notify Send out fault notifications.
+ *
+ * @return Zero on success or an error code from errno.h.
+ *
+ */
+void task_kill_self(bool notify)
+{
+	/*
+	 * User space can subscribe for FAULT events to take action
+	 * whenever a task faults (to take a dump, run a debugger, etc.).
+	 * The notification is always available, but unless udebug is enabled,
+	 * that's all you get.
+	*/
+	if (notify) {
+		if (event_is_subscribed(EVENT_FAULT)) {
+			/* Notify the subscriber that a fault occurred. */
+			event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
+			    UPPER32(TASK->taskid), (sysarg_t) THREAD);
+		
+#ifdef CONFIG_UDEBUG
+			/* Wait for a debugging session. */
+			udebug_thread_fault();
+#endif
+		}
+	}
+	
+	irq_spinlock_lock(&tasks_lock, true);
+	task_kill_internal(TASK);
+	irq_spinlock_unlock(&tasks_lock, true);
+	
+	thread_exit();
+}
+
+/** Process syscall to terminate the current task.
+ *
+ * @param notify Send out fault notifications.
+ *
+ */
+sysarg_t sys_task_exit(sysarg_t notify)
+{
+	task_kill_self(notify);
+	
+	/* Unreachable */
+	return EOK;
+}
+
 static bool task_print_walker(avltree_node_t *node, void *arg)
 {
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/syscall/syscall.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -87,6 +87,5 @@
 	} else {
 		printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id);
-		task_kill(TASK->taskid);
-		thread_exit();
+		task_kill_self(true);
 	}
 	
@@ -132,4 +131,5 @@
 	(syshandler_t) sys_task_set_name,
 	(syshandler_t) sys_task_kill,
+	(syshandler_t) sys_task_exit,
 	(syshandler_t) sys_program_spawn_loader,
 	
@@ -144,4 +144,5 @@
 	(syshandler_t) sys_as_area_change_flags,
 	(syshandler_t) sys_as_area_destroy,
+	(syshandler_t) sys_as_get_unmapped_area,
 	
 	/* Page mapping related syscalls. */
@@ -160,6 +161,4 @@
 	(syshandler_t) sys_ipc_poke,
 	(syshandler_t) sys_ipc_hangup,
-	(syshandler_t) sys_ipc_register_irq,
-	(syshandler_t) sys_ipc_unregister_irq,
 	(syshandler_t) sys_ipc_connect_kbox,
 	
@@ -175,4 +174,6 @@
 	(syshandler_t) sys_physmem_map,
 	(syshandler_t) sys_iospace_enable,
+	(syshandler_t) sys_register_irq,
+	(syshandler_t) sys_unregister_irq,
 	
 	/* Sysinfo syscalls */
Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/sysinfo/stats.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -160,69 +160,17 @@
 static size_t get_task_virtmem(as_t *as)
 {
-	size_t result = 0;
-
 	/*
-	 * We are holding some spinlocks here and therefore are not allowed to
-	 * block. Only attempt to lock the address space and address space area
-	 * mutexes conditionally. If it is not possible to lock either object,
-	 * allow the statistics to be inexact by skipping the respective object.
-	 *
-	 * Note that it may be infinitely better to let the address space
-	 * management code compute these statistics as it proceeds instead of
-	 * having them calculated over and over again here.
+	 * We are holding spinlocks here and therefore are not allowed to
+	 * block. Only attempt to lock the address space and address space
+	 * area mutexes conditionally. If it is not possible to lock either
+	 * object, return inexact statistics by skipping the respective object.
 	 */
-
+	
 	if (SYNCH_FAILED(mutex_trylock(&as->lock)))
-		return result * PAGE_SIZE;
+		return 0;
+	
+	size_t pages = 0;
 	
 	/* Walk the B+ tree and count pages */
-	link_t *cur;
-	for (cur = as->as_area_btree.leaf_head.next;
-	    cur != &as->as_area_btree.leaf_head; cur = cur->next) {
-		btree_node_t *node =
-		    list_get_instance(cur, btree_node_t, leaf_link);
-		
-		unsigned int i;
-		for (i = 0; i < node->keys; i++) {
-			as_area_t *area = node->value[i];
-			
-			if (SYNCH_FAILED(mutex_trylock(&area->lock)))
-				continue;
-			result += area->pages;
-			mutex_unlock(&area->lock);
-		}
-	}
-	
-	mutex_unlock(&as->lock);
-	
-	return result * PAGE_SIZE;
-}
-
-/** Get the resident (used) size of a virtual address space
- *
- * @param as Address space.
- *
- * @return Size of the resident (used) virtual address space (bytes).
- *
- */
-static size_t get_task_resmem(as_t *as)
-{
-	size_t result = 0;
-	
-	/*
-	 * We are holding some spinlocks here and therefore are not allowed to
-	 * block. Only attempt to lock the address space and address space area
-	 * mutexes conditionally. If it is not possible to lock either object,
-	 * allow the statistics to be inexact by skipping the respective object.
-	 *
-	 * Note that it may be infinitely better to let the address space
-	 * management code compute these statistics as it proceeds instead of
-	 * having them calculated over and over again here.
-	 */
-	
-	if (SYNCH_FAILED(mutex_trylock(&as->lock)))
-		return result * PAGE_SIZE;
-	
-	/* Walk the B+ tree of AS areas */
 	link_t *cur;
 	for (cur = as->as_area_btree.leaf_head.next;
@@ -238,16 +186,5 @@
 				continue;
 			
-			/* Walk the B+ tree of resident pages */
-			link_t *rcur;
-			for (rcur = area->used_space.leaf_head.next;
-			    rcur != &area->used_space.leaf_head; rcur = rcur->next) {
-				btree_node_t *rnode =
-				    list_get_instance(rcur, btree_node_t, leaf_link);
-				
-				unsigned int j;
-				for (j = 0; j < rnode->keys; j++)
-					result += (size_t) rnode->value[i];
-			}
-			
+			pages += area->pages;
 			mutex_unlock(&area->lock);
 		}
@@ -256,5 +193,50 @@
 	mutex_unlock(&as->lock);
 	
-	return result * PAGE_SIZE;
+	return (pages << PAGE_WIDTH);
+}
+
+/** Get the resident (used) size of a virtual address space
+ *
+ * @param as Address space.
+ *
+ * @return Size of the resident (used) virtual address space (bytes).
+ *
+ */
+static size_t get_task_resmem(as_t *as)
+{
+	/*
+	 * We are holding spinlocks here and therefore are not allowed to
+	 * block. Only attempt to lock the address space and address space
+	 * area mutexes conditionally. If it is not possible to lock either
+	 * object, return inexact statistics by skipping the respective object.
+	 */
+	
+	if (SYNCH_FAILED(mutex_trylock(&as->lock)))
+		return 0;
+	
+	size_t pages = 0;
+	
+	/* Walk the B+ tree and count pages */
+	link_t *cur;
+	for (cur = as->as_area_btree.leaf_head.next;
+	    cur != &as->as_area_btree.leaf_head; cur = cur->next) {
+		btree_node_t *node =
+		    list_get_instance(cur, btree_node_t, leaf_link);
+		
+		unsigned int i;
+		for (i = 0; i < node->keys; i++) {
+			as_area_t *area = node->value[i];
+			
+			if (SYNCH_FAILED(mutex_trylock(&area->lock)))
+				continue;
+			
+			pages += area->resident;
+			mutex_unlock(&area->lock);
+		}
+	}
+	
+	mutex_unlock(&as->lock);
+	
+	return (pages << PAGE_WIDTH);
 }
 
Index: kernel/generic/src/time/clock.c
===================================================================
--- kernel/generic/src/time/clock.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ kernel/generic/src/time/clock.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -93,4 +93,5 @@
 	clock_parea.pbase = (uintptr_t) faddr;
 	clock_parea.frames = 1;
+	clock_parea.unpriv = true;
 	ddi_parea_register(&clock_parea);
 	
@@ -100,5 +101,4 @@
 	 *
 	 */
-	sysinfo_set_item_val("clock.cacheable", NULL, (sysarg_t) true);
 	sysinfo_set_item_val("clock.faddr", NULL, (sysarg_t) faddr);
 }
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/Makefile.common	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -138,4 +138,11 @@
 endif
 
+ifeq ($(CONFIG_LINE_DEBUG),y)
+	GCC_CFLAGS += -g
+	ICC_CFLAGS += -g
+	SUNCC_CFLAGS += -g
+	CLANG_CFLAGS += -g
+endif
+
 ## Setup platform configuration
 #
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/init/init.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 #include <stdio.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <vfs/vfs.h>
 #include <bool.h>
Index: uspace/app/klog/klog.c
===================================================================
--- uspace/app/klog/klog.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/klog/klog.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,13 +36,12 @@
 
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <async.h>
-#include <ipc/services.h>
 #include <as.h>
-#include <sysinfo.h>
+#include <ddi.h>
 #include <event.h>
 #include <errno.h>
 #include <str_error.h>
 #include <io/klog.h>
+#include <sysinfo.h>
 
 #define NAME       "klog"
@@ -79,29 +78,42 @@
 int main(int argc, char *argv[])
 {
-	size_t klog_pages;
-	if (sysinfo_get_value("klog.pages", &klog_pages) != EOK) {
-		printf("%s: Error getting klog address\n", NAME);
-		return -1;
+	size_t pages;
+	int rc = sysinfo_get_value("klog.pages", &pages);
+	if (rc != EOK) {
+		fprintf(stderr, "%s: Unable to get number of klog pages\n",
+		    NAME);
+		return rc;
 	}
 	
-	size_t klog_size = klog_pages * PAGE_SIZE;
-	klog_length = klog_size / sizeof(wchar_t);
-	
-	klog = (wchar_t *) as_get_mappable_page(klog_size);
-	if (klog == NULL) {
-		printf("%s: Error allocating memory area\n", NAME);
-		return -1;
+	uintptr_t faddr;
+	rc = sysinfo_get_value("klog.faddr", &faddr);
+	if (rc != EOK) {
+		fprintf(stderr, "%s: Unable to get klog physical address\n",
+		    NAME);
+		return rc;
 	}
 	
-	int res = async_share_in_start_1_0(PHONE_NS, (void *) klog,
-	    klog_size, SERVICE_MEM_KLOG);
-	if (res != EOK) {
-		printf("%s: Error initializing memory area\n", NAME);
-		return -1;
+	size_t size = pages * PAGE_SIZE;
+	klog_length = size / sizeof(wchar_t);
+	
+	klog = (wchar_t *) as_get_mappable_page(size);
+	if (klog == NULL) {
+		fprintf(stderr, "%s: Unable to allocate virtual memory area\n",
+		    NAME);
+		return ENOMEM;
 	}
 	
-	if (event_subscribe(EVENT_KLOG, 0) != EOK) {
-		printf("%s: Error registering klog notifications\n", NAME);
-		return -1;
+	rc = physmem_map((void *) faddr, (void *) klog, pages,
+	    AS_AREA_READ | AS_AREA_CACHEABLE);
+	if (rc != EOK) {
+		fprintf(stderr, "%s: Unable to map klog\n", NAME);
+		return rc;
+	}
+	
+	rc = event_subscribe(EVENT_KLOG, 0);
+	if (rc != EOK) {
+		fprintf(stderr, "%s: Unable to register klog notifications\n",
+		    NAME);
+		return rc;
 	}
 	
@@ -109,5 +121,4 @@
 	 * Mode "a" would be definitively much better here, but it is
 	 * not well supported by the FAT driver.
-	 *
 	 */
 	log = fopen(LOG_FNAME, "w");
Index: uspace/app/ping/ping.c
===================================================================
--- uspace/app/ping/ping.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/ping/ping.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,9 +35,9 @@
  */
 
+#include <async.h>
 #include <stdio.h>
 #include <str.h>
 #include <task.h>
 #include <time.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <str_error.h>
@@ -355,5 +355,5 @@
 			    str_error(ret));
 			
-			ipc_hangup(icmp_phone);
+			async_hangup(icmp_phone);
 			return ret;
 		}
@@ -370,5 +370,5 @@
 			    str_error(ret));
 			
-			ipc_hangup(icmp_phone);
+			async_hangup(icmp_phone);
 			return ret;
 		}
@@ -390,5 +390,5 @@
 	}
 	
-	ipc_hangup(icmp_phone);
+	async_hangup(icmp_phone);
 	
 	return 0;
Index: uspace/app/taskdump/taskdump.c
===================================================================
--- uspace/app/taskdump/taskdump.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/taskdump/taskdump.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,8 +33,8 @@
  */
 
+#include <async.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <errno.h>
 #include <udebug.h>
@@ -105,5 +105,5 @@
 
 	udebug_end(phoneid);
-	ipc_hangup(phoneid);
+	async_hangup(phoneid);
 
 	return 0;
@@ -114,5 +114,5 @@
 	int rc;
 
-	rc = ipc_connect_kbox(task_id);
+	rc = async_connect_kbox(task_id);
 
 	if (rc == ENOTSUP) {
@@ -126,5 +126,5 @@
 	if (rc < 0) {
 		printf("Error connecting\n");
-		printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc);
+		printf("async_connect_kbox(%" PRIu64 ") -> %d ", task_id, rc);
 		return rc;
 	}
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -89,5 +89,5 @@
 	/* Clean-up. */
 	TPRINTF(" Closing phones and file descriptors\n");
-	ipc_hangup(phone);
+	async_hangup(phone);
 	close(fd);
 	
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/tester/hw/serial/serial1.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <sys/types.h>
 #include <async.h>
@@ -88,5 +87,5 @@
 	char *buf = (char *) malloc(cnt + 1);
 	if (buf == NULL) {
-		ipc_hangup(phone);
+		async_hangup(phone);
 		devman_hangup_phone(DEVMAN_CLIENT);
 		return "Failed to allocate input buffer";
@@ -98,18 +97,18 @@
 	sysarg_t old_word_size;
 	
-	res = ipc_call_sync_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
+	res = async_req_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
 	    &old_par, &old_word_size, &old_stop);
 	if (res != EOK) {
 		free(buf);
-		ipc_hangup(phone);
+		async_hangup(phone);
 		devman_hangup_phone(DEVMAN_CLIENT);
 		return "Failed to get old serial communication parameters";
 	}
 	
-	res = ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
+	res = async_req_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
 	    SERIAL_NO_PARITY, 8, 1);
 	if (EOK != res) {
 		free(buf);
-		ipc_hangup(phone);
+		async_hangup(phone);
 		devman_hangup_phone(DEVMAN_CLIENT);
 		return "Failed to set serial communication parameters";
@@ -124,8 +123,8 @@
 		
 		if (read < 0) {
-			ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+			async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
 			    old_par, old_word_size, old_stop);
 			free(buf);
-			ipc_hangup(phone);
+			async_hangup(phone);
 			devman_hangup_phone(DEVMAN_CLIENT);
 			return "Failed read from serial device";
@@ -133,8 +132,8 @@
 		
 		if ((size_t) read > cnt - total) {
-			ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+			async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
 			    old_par, old_word_size, old_stop);
 			free(buf);
-			ipc_hangup(phone);
+			async_hangup(phone);
 			devman_hangup_phone(DEVMAN_CLIENT);
 			return "Read more data than expected";
@@ -155,8 +154,8 @@
 			
 			if (written < 0) {
-				ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+				async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
 				    old_par, old_word_size, old_stop);
 				free(buf);
-				ipc_hangup(phone);
+				async_hangup(phone);
 				devman_hangup_phone(DEVMAN_CLIENT);
 				return "Failed write to serial device";
@@ -164,8 +163,8 @@
 			
 			if (written != read) {
-				ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+				async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
 				    old_par, old_word_size, old_stop);
 				free(buf);
-				ipc_hangup(phone);
+				async_hangup(phone);
 				devman_hangup_phone(DEVMAN_CLIENT);
 				return "Written less data than read from serial device";
@@ -183,8 +182,8 @@
 	ssize_t written = char_dev_write(phone, (void *) EOT, eot_size);
 	
-	ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
+	async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
 	    old_par, old_word_size, old_stop);
 	free(buf);
-	ipc_hangup(phone);
+	async_hangup(phone);
 	devman_hangup_phone(DEVMAN_CLIENT);
 	
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/tester/tester.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #include <sys/types.h>
 #include <bool.h>
-#include <ipc/ipc.h>
 
 #define IPC_TEST_SERVICE  10240
Index: uspace/app/tetris/screen.h
===================================================================
--- uspace/app/tetris/screen.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/tetris/screen.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -48,5 +48,4 @@
 
 #include <sys/types.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <bool.h>
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/top/screen.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <io/console.h>
 #include <io/style.h>
Index: uspace/app/trace/ipc_desc.c
===================================================================
--- uspace/app/trace/ipc_desc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/ipc_desc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,6 +33,6 @@
  */
 
+#include <ipc/common.h>
 #include <stdlib.h>
-#include <ipc/ipc.h>
 #include "ipc_desc.h"
 
Index: uspace/app/trace/ipcp.h
===================================================================
--- uspace/app/trace/ipcp.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/ipcp.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define IPCP_H_
 
-#include <ipc/ipc.h>
 #include "proto.h"
 
Index: uspace/app/trace/proto.c
===================================================================
--- uspace/app/trace/proto.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/proto.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <ipc/ipc.h>
 #include <adt/hash_table.h>
 
Index: uspace/app/trace/proto.h
===================================================================
--- uspace/app/trace/proto.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/proto.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,6 +36,6 @@
 #define PROTO_H_
 
+#include <ipc/common.h>
 #include <adt/hash_table.h>
-#include <ipc/ipc.h>
 #include "trace.h"
 
Index: uspace/app/trace/syscalls.c
===================================================================
--- uspace/app/trace/syscalls.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/syscalls.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -64,6 +64,4 @@
     [SYS_IPC_POKE] = { "ipc_poke",			0,	V_ERRNO },
     [SYS_IPC_HANGUP] = { "ipc_hangup",			1,	V_ERRNO },
-    [SYS_IPC_REGISTER_IRQ] = { "ipc_register_irq",	4,	V_ERRNO },
-    [SYS_IPC_UNREGISTER_IRQ] = { "ipc_unregister_irq",	2,	V_ERRNO },
 
     [SYS_EVENT_SUBSCRIBE] = { "event_subscribe",	2,	V_ERRNO },
@@ -73,4 +71,6 @@
     [SYS_PHYSMEM_MAP] = { "physmem_map",		4,	V_ERRNO },
     [SYS_IOSPACE_ENABLE] = { "iospace_enable",		1,	V_ERRNO },
+    [SYS_REGISTER_IRQ] = { "register_irq",	4,	V_ERRNO },
+    [SYS_UNREGISTER_IRQ] = { "unregister_irq",	2,	V_ERRNO },
 
     [SYS_SYSINFO_GET_TAG] = { "sysinfo_get_tag",		2,	V_INTEGER },
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/trace/trace.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #include <stdlib.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <fibril.h>
 #include <errno.h>
@@ -149,5 +148,5 @@
 	int rc;
 
-	rc = ipc_connect_kbox(task_id);
+	rc = async_connect_kbox(task_id);
 
 	if (rc == ENOTSUP) {
@@ -745,5 +744,5 @@
 	abort_trace = true;
 	udebug_end(phoneid);
-	ipc_hangup(phoneid);
+	async_hangup(phoneid);
 
 	ipcp_cleanup();
Index: uspace/app/usbinfo/info.c
===================================================================
--- uspace/app/usbinfo/info.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/app/usbinfo/info.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -141,5 +141,5 @@
 leave:
 	/* Ignoring errors here. */
-	ipc_hangup(hc_phone);
+	async_hangup(hc_phone);
 	usb_endpoint_pipe_end_session(&ctrl_pipe);
 
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/ns8250/ns8250.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -256,5 +256,5 @@
 	
 	if (dev->parent_phone > 0) {
-		ipc_hangup(dev->parent_phone);
+		async_hangup(dev->parent_phone);
 		dev->parent_phone = 0;
 	}
@@ -888,5 +888,5 @@
 		ns8250_get_props(dev, &baud_rate, &parity, &word_length,
 		    &stop_bits);
-		ipc_answer_4(callid, EOK, baud_rate, parity, word_length,
+		async_answer_4(callid, EOK, baud_rate, parity, word_length,
 		    stop_bits);
 		break;
@@ -899,9 +899,9 @@
 		ret = ns8250_set_props(dev, baud_rate, parity, word_length,
 		    stop_bits);
-		ipc_answer_0(callid, ret);
+		async_answer_0(callid, ret);
 		break;
 		
 	default:
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 	}
 }
Index: uspace/drv/pciintel/pci.c
===================================================================
--- uspace/drv/pciintel/pci.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/pciintel/pci.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -478,5 +478,5 @@
 		    "the device.\n");
 		delete_pci_bus_data(bus_data);
-		ipc_hangup(dev->parent_phone);
+		async_hangup(dev->parent_phone);
 		return rc;
 	}	
@@ -496,5 +496,5 @@
 		printf(NAME ": failed to enable configuration ports.\n");
 		delete_pci_bus_data(bus_data);
-		ipc_hangup(dev->parent_phone);
+		async_hangup(dev->parent_phone);
 		hw_res_clean_resource_list(&hw_resources);
 		return EADDRNOTAVAIL;
Index: uspace/drv/test2/test2.c
===================================================================
--- uspace/drv/test2/test2.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/test2/test2.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -103,4 +103,8 @@
 	if (dev->parent == NULL) {
 		fid_t postpone = fibril_create(postponed_birth, dev);
+		if (postpone == 0) {
+			printf(NAME ": fibril_create() error\n");
+			return ENOMEM;
+		}
 		fibril_add_ready(postpone);
 	} else {
Index: uspace/drv/uhci-hcd/pci.c
===================================================================
--- uspace/drv/uhci-hcd/pci.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/uhci-hcd/pci.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -117,5 +117,5 @@
 	rc = EOK;
 leave:
-	ipc_hangup(parent_phone);
+	async_hangup(parent_phone);
 
 	return rc;
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/usbhid/main.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -83,14 +83,14 @@
 
 		if (console_callback_phone != -1) {
-			ipc_answer_0(icallid, ELIMIT);
+			async_answer_0(icallid, ELIMIT);
 			return;
 		}
 
 		console_callback_phone = callback;
-		ipc_answer_0(icallid, EOK);
+		async_answer_0(icallid, EOK);
 		return;
 	}
 
-	ipc_answer_0(icallid, EINVAL);
+	async_answer_0(icallid, EINVAL);
 }
 
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/usbhub/usbhub.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -199,5 +199,5 @@
 	//ports powered, hub seems to be enabled
 
-	ipc_hangup(hc);
+	async_hangup(hc);
 
 	//add the hub to list
@@ -502,5 +502,5 @@
 		free(change_bitmap);
 
-		ipc_hangup(hc);
+		async_hangup(hc);
 		fibril_mutex_lock(&usb_hub_list_lock);
 	}
Index: uspace/drv/vhc/conndev.c
===================================================================
--- uspace/drv/vhc/conndev.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/vhc/conndev.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -90,9 +90,9 @@
 		    = virtdev_add_device(callback, (sysarg_t)fibril_get_id());
 		if (!dev) {
-			ipc_answer_0(icallid, EEXISTS);
-			ipc_hangup(callback);
+			async_answer_0(icallid, EEXISTS);
+			async_hangup(callback);
 			return;
 		}
-		ipc_answer_0(icallid, EOK);
+		async_answer_0(icallid, EOK);
 
 		char devname[DEVICE_NAME_MAXLENGTH + 1];
@@ -105,5 +105,5 @@
 	}
 
-	ipc_answer_0(icallid, EINVAL);
+	async_answer_0(icallid, EINVAL);
 }
 
Index: uspace/drv/vhc/devices.c
===================================================================
--- uspace/drv/vhc/devices.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/vhc/devices.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <adt/list.h>
 #include <bool.h>
Index: uspace/drv/vhc/hc.c
===================================================================
--- uspace/drv/vhc/hc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/vhc/hc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <adt/list.h>
 #include <bool.h>
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/drv/vhc/hcd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
 
 #include <devmap.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <unistd.h>
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/block/libblock.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -44,5 +44,4 @@
 #include <sys/mman.h>
 #include <async.h>
-#include <ipc/ipc.h>
 #include <as.h>
 #include <assert.h>
@@ -177,5 +176,5 @@
 	if (rc != EOK) {
 	    	munmap(comm_area, comm_size);
-		ipc_hangup(dev_phone);
+		async_hangup(dev_phone);
 		return rc;
 	}
@@ -183,5 +182,5 @@
 	if (get_block_size(dev_phone, &bsize) != EOK) {
 		munmap(comm_area, comm_size);
-		ipc_hangup(dev_phone);
+		async_hangup(dev_phone);
 		return rc;
 	}
@@ -190,5 +189,5 @@
 	if (rc != EOK) {
 		munmap(comm_area, comm_size);
-		ipc_hangup(dev_phone);
+		async_hangup(dev_phone);
 		return rc;
 	}
@@ -211,5 +210,5 @@
 
 	munmap(devcon->comm_area, devcon->comm_size);
-	ipc_hangup(devcon->dev_phone);
+	async_hangup(devcon->dev_phone);
 
 	free(devcon);	
@@ -295,6 +294,8 @@
 
 	/* Allow 1:1 or small-to-large block size translation */
-	if (cache->lblock_size % devcon->pblock_size != 0)
+	if (cache->lblock_size % devcon->pblock_size != 0) {
+		free(cache);
 		return ENOTSUP;
+	}
 
 	cache->blocks_cluster = cache->lblock_size / devcon->pblock_size;
@@ -437,4 +438,5 @@
 			if (!b->data) {
 				free(b);
+				b = NULL;
 				goto recycle;
 			}
@@ -564,4 +566,5 @@
 	assert(devcon);
 	assert(devcon->cache);
+	assert(block->refcnt >= 1);
 
 	cache = devcon->cache;
@@ -623,6 +626,6 @@
 			unsigned long key = block->lba;
 			hash_table_remove(&cache->block_hash, &key, 1);
+			free(block->data);
 			free(block);
-			free(block->data);
 			cache->blocks_cached--;
 			fibril_mutex_unlock(&cache->lock);
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/Makefile	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -83,4 +83,5 @@
 	generic/io/console.c \
 	generic/io/screenbuffer.c \
+	generic/ipc/ns.c \
 	generic/malloc.c \
 	generic/sysinfo.c \
@@ -96,5 +97,4 @@
 	generic/adt/char_map.c \
 	generic/time.c \
-	generic/err.c \
 	generic/stdlib.c \
 	generic/mman.c \
Index: uspace/lib/c/arch/abs32le/_link.ld.in
===================================================================
--- uspace/lib/c/arch/abs32le/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/abs32le/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -44,8 +44,4 @@
 	} :data
 	
-	. = ALIGN(0x1000);
-	
-	_heap = .;
-	
 	/DISCARD/ : {
 		*(*);
Index: uspace/lib/c/arch/abs32le/src/entry.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/entry.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/abs32le/src/entry.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -30,12 +30,11 @@
  */
 
-#include <libc.h>
 #include <unistd.h>
 #include <libarch/entry.h>
+#include "../../../generic/private/libc.h"
 
 void __entry(void)
 {
 	__main(NULL);
-	__exit();
 }
 
Index: uspace/lib/c/arch/abs32le/src/thread_entry.c
===================================================================
--- uspace/lib/c/arch/abs32le/src/thread_entry.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/abs32le/src/thread_entry.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,5 +31,5 @@
 
 #include <unistd.h>
-#include <thread.h>
+#include "../../../generic/private/thread.h"
 
 void __thread_entry(void)
Index: uspace/lib/c/arch/amd64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/amd64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/amd64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -5,4 +5,5 @@
 	text PT_LOAD FLAGS(5);
 	data PT_LOAD FLAGS(6);
+	debug PT_NOTE;
 }
 
@@ -13,14 +14,16 @@
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x1000;
-
+	
 	.data : {
 		*(.data);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -31,16 +34,27 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = ALIGNOF(.tdata);
+	
 	.bss : {
 		*(COMMON);
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x1000);
-	_heap = .;
+	
+#ifdef CONFIG_LINE_DEBUG
+	.comment 0 : { *(.comment); } :debug
+	.debug_abbrev 0 : { *(.debug_abbrev); } :debug
+	.debug_aranges 0 : { *(.debug_aranges); } :debug
+	.debug_info 0 : { *(.debug_info); } :debug
+	.debug_line 0 : { *(.debug_line); } :debug
+	.debug_loc 0 : { *(.debug_loc); } :debug
+	.debug_pubnames 0 : { *(.debug_pubnames); } :debug
+	.debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
+	.debug_ranges 0 : { *(.debug_ranges); } :debug
+	.debug_str 0 : { *(.debug_str); } :debug
+#endif
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/lib/c/arch/amd64/src/entry.s
===================================================================
--- uspace/lib/c/arch/amd64/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/amd64/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -47,4 +47,2 @@
 	# Pass PCB pointer to __main (no operation)
 	call __main
-
-	call __exit
Index: uspace/lib/c/arch/arm32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/arm32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/arm32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -9,15 +9,16 @@
 SECTIONS {
 	. = 0x1000 + SIZEOF_HEADERS;
-
+	
 	.init : {
 		*(.init);
-	} : text
+	} :text
+	
 	.text : {
 		*(.text);
-        *(.rodata*);
+		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x1000;
-
+	
 	.data : {
 		*(.opd);
@@ -25,4 +26,5 @@
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -33,18 +35,16 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = ALIGNOF(.tdata);
+	
 	.bss : {
 		*(.sbss);
 		*(.scommon);
-        *(COMMON);
-        *(.bss);
+		*(COMMON);
+		*(.bss);
 	} :data
-	
-	. = ALIGN(0x1000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/lib/c/arch/arm32/src/entry.s
===================================================================
--- uspace/lib/c/arch/arm32/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/arm32/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,5 +42,5 @@
 	ldr r0, =ras_page
 	str r2, [r0]
-
+	
 	#
 	# Create the first stack frame.
@@ -50,10 +50,8 @@
 	push {fp, ip, lr, pc}
 	sub fp, ip, #4
-
+	
 	# Pass pcb_ptr to __main as the first argument (in r0)
 	mov r0, r1
 	bl __main
-
-	bl __exit
 
 .data
@@ -62,3 +60,2 @@
 ras_page:
 	.long 0
-
Index: uspace/lib/c/arch/ia32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ia32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -5,4 +5,5 @@
 	text PT_LOAD FLAGS(5);
 	data PT_LOAD FLAGS(6);
+	debug PT_NOTE;
 }
 
@@ -42,7 +43,16 @@
 	} :data
 	
-	. = ALIGN(0x1000);
-	
-	_heap = .;
+#ifdef CONFIG_LINE_DEBUG
+	.comment 0 : { *(.comment); } :debug
+	.debug_abbrev 0 : { *(.debug_abbrev); } :debug
+	.debug_aranges 0 : { *(.debug_aranges); } :debug
+	.debug_info 0 : { *(.debug_info); } :debug
+	.debug_line 0 : { *(.debug_line); } :debug
+	.debug_loc 0 : { *(.debug_loc); } :debug
+	.debug_pubnames 0 : { *(.debug_pubnames); } :debug
+	.debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
+	.debug_ranges 0 : { *(.debug_ranges); } :debug
+	.debug_str 0 : { *(.debug_str); } :debug
+#endif
 	
 	/DISCARD/ : {
Index: uspace/lib/c/arch/ia32/src/entry.s
===================================================================
--- uspace/lib/c/arch/ia32/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ia32/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -46,5 +46,5 @@
 	mov %ax, %fs
 	# Do not set %gs, it contains descriptor that can see TLS
-
+	
 	# Detect the mechanism used for making syscalls
 	movl $(INTEL_CPUID_STANDARD), %eax
@@ -58,10 +58,8 @@
 	# Create the first stack frame.
 	#
-	pushl $0 
+	pushl $0
 	movl %esp, %ebp
-
+	
 	# Pass the PCB pointer to __main as the first argument
 	pushl %edi
 	call __main
-
-	call __exit
Index: uspace/lib/c/arch/ia64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ia64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -9,19 +9,21 @@
 SECTIONS {
 	. = 0x4000 + SIZEOF_HEADERS;
-
+	
 	.init : {
 		*(.init);
-	} : text
+	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x4000;
-
+	
 	.got : {
 		_gp = .;
 		*(.got*);
-	} :data	
+	} :data
+	
 	.data : {
 		*(.opd);
@@ -29,4 +31,5 @@
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -37,5 +40,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = ALIGNOF(.tdata);
+	
 	.bss : {
 		*(.sbss);
@@ -44,10 +49,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
- 
+	
 	/DISCARD/ : {
 		*(*);
-        }
+	}
 }
Index: uspace/lib/c/arch/ia64/src/entry.s
===================================================================
--- uspace/lib/c/arch/ia64/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ia64/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,8 +40,6 @@
 	alloc loc0 = ar.pfs, 0, 1, 2, 0
 	movl gp = _gp
-
+	
 	# Pass PCB pointer as the first argument to __main
 	mov out0 = r2
 	br.call.sptk.many b0 = __main
-0:
-	br.call.sptk.many b0 = __exit
Index: uspace/lib/c/arch/mips32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/mips32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -13,43 +13,46 @@
 		*(.init);
 	} :text
+	
 	.text : {
-	        *(.text);
+		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x4000;
-
+	
 	.data : {
 		*(.data);
 		*(.data.rel*);
 	} :data
-
+	
 	.got : {
 		_gp = .;
 		*(.got);
 	} :data
-
+	
 	.tdata : {
 		_tdata_start = .;
 		*(.tdata);
 		_tdata_end = .;
+	} :data
+	
+	.tbss : {
 		_tbss_start = .;
 		*(.tbss);
 		_tbss_end = .;
 	} :data
-	_tls_alignment = ALIGNOF(.tdata);
-
+	
+	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.sbss : {
 		*(.scommon);
 		*(.sbss);
-	}	
+	}
+	
 	.bss : {
 		*(.bss);
 		*(COMMON);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
-
+	
 	/DISCARD/ : {
 		*(*);
Index: uspace/lib/c/arch/mips32/src/entry.s
===================================================================
--- uspace/lib/c/arch/mips32/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/mips32/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -29,6 +29,7 @@
 .text
 .section .init, "ax"
+
 .global __entry
-.global __entry_driver
+
 .set noreorder
 .option pic2
@@ -56,10 +57,3 @@
 	jal __main
 	nop
-	
-	jal __exit
-	nop
 .end
-
-# Alignment of output section data to 0x4000
-.section .data
-.align 14
Index: uspace/lib/c/arch/ppc32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ppc32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ppc32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -9,19 +9,21 @@
 SECTIONS {
 	. = 0x1000 + SIZEOF_HEADERS;
-
+	
 	.init : {
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x1000;
-
+	
 	.data : {
 		*(.data);
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -32,5 +34,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = ALIGNOF(.tdata);
+	
 	.bss : {
 		*(.sbss);
@@ -38,11 +42,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x1000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/lib/c/arch/ppc32/src/entry.s
===================================================================
--- uspace/lib/c/arch/ppc32/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/ppc32/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -44,9 +44,7 @@
 	stw %r3, 0(%r1)
 	stwu %r1, -16(%r1)
-
+	
 	# Pass the PCB pointer to __main() as the first argument.
 	# The first argument is passed in r3.
 	mr %r3, %r6
 	bl __main
-
-	bl __exit
Index: uspace/lib/c/arch/sparc64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/sparc64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/sparc64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -9,23 +9,26 @@
 SECTIONS {
 	. = 0x4000 + SIZEOF_HEADERS;
-
+	
 	.init : {
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x4000;
-
+	
 	.got : {
 		 _gp = .;
 		 *(.got*);
 	} :data
+	
 	.data : {
 		*(.data);
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -36,5 +39,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = ALIGNOF(.tdata);
+	
 	.bss : {
 		*(.sbss);
@@ -42,11 +47,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/lib/c/arch/sparc64/src/entry.s
===================================================================
--- uspace/lib/c/arch/sparc64/src/entry.s	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/arch/sparc64/src/entry.s	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,5 +45,5 @@
 	flushw
 	add %g0, -0x7ff, %fp
-
+	
 	# Pass pcb_ptr as the first argument to __main()
 	mov %i1, %o0
@@ -51,5 +51,2 @@
 	call __main
 	or %l7, %lo(_gp), %l7
-
-	call __exit
-	nop
Index: uspace/lib/c/generic/as.c
===================================================================
--- uspace/lib/c/generic/as.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/as.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,7 +41,5 @@
 #include <bitops.h>
 #include <malloc.h>
-
-/** Last position allocated by as_get_mappable_page */
-static uintptr_t last_allocated = 0;
+#include "private/libc.h"
 
 /** Create address space area.
@@ -104,27 +102,15 @@
 }
 
-/** Return pointer to some unmapped area, where fits new as_area
+/** Return pointer to unmapped address space area
  *
  * @param size Requested size of the allocation.
  *
- * @return pointer to the beginning
+ * @return Pointer to the beginning of unmapped address space area.
  *
  */
 void *as_get_mappable_page(size_t size)
 {
-	if (size == 0)
-		return NULL;
-	
-	size_t sz = 1 << (fnzb(size - 1) + 1);
-	if (last_allocated == 0)
-		last_allocated = get_max_heap_addr();
-	
-	/*
-	 * Make sure we allocate from naturally aligned address.
-	 */
-	uintptr_t res = ALIGN_UP(last_allocated, sz);
-	last_allocated = res + ALIGN_UP(size, PAGE_SIZE);
-	
-	return ((void *) res);
+	return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA,
+	    (sysarg_t) __entry, (sysarg_t) size);
 }
 
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/async.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,9 +43,4 @@
  * framework will automatically take care of most synchronization problems.
  *
- * Default semantics:
- * - async_send_*(): Send asynchronously. If the kernel refuses to send
- *                   more messages, [ try to get responses from kernel, if
- *                   nothing found, might try synchronous ]
- *
  * Example of use (pseudo C):
  *
@@ -58,5 +53,5 @@
  *   int fibril1(void *arg)
  *   {
- *     conn = ipc_connect_me_to();
+ *     conn = async_connect_me_to();
  *     c1 = async_send(conn);
  *     c2 = async_send(conn);
@@ -77,12 +72,12 @@
  *   {
  *     if (want_refuse) {
- *       ipc_answer_0(icallid, ELIMIT);
+ *       async_answer_0(icallid, ELIMIT);
  *       return;
  *     }
- *     ipc_answer_0(icallid, EOK);
+ *     async_answer_0(icallid, EOK);
  *
  *     callid = async_get_call(&call);
  *     somehow_handle_the_call(callid, call);
- *     ipc_answer_2(callid, 1, 2, 3);
+ *     async_answer_2(callid, 1, 2, 3);
  *
  *     callid = async_get_call(&call);
@@ -92,12 +87,14 @@
  */
 
+#define LIBC_ASYNC_C_
+#include <ipc/ipc.h>
+#include <async.h>
+#undef LIBC_ASYNC_C_
+
 #include <futex.h>
-#include <async.h>
-#include <async_priv.h>
 #include <fibril.h>
 #include <stdio.h>
 #include <adt/hash_table.h>
 #include <adt/list.h>
-#include <ipc/ipc.h>
 #include <assert.h>
 #include <errno.h>
@@ -105,4 +102,5 @@
 #include <arch/barrier.h>
 #include <bool.h>
+#include "private/async.h"
 
 atomic_t async_futex = FUTEX_INITIALIZER;
@@ -124,6 +122,6 @@
 
 /**
- * Structures of this type are used to group information about a call and a
- * message queue link.
+ * Structures of this type are used to group information about
+ * a call and about a message queue link.
  */
 typedef struct {
@@ -153,5 +151,5 @@
 	/** Link to the client tracking structure. */
 	client_t *client;
-
+	
 	/** Messages that should be delivered to this fibril. */
 	link_t msg_queue;
@@ -170,5 +168,5 @@
 
 /** Identifier of the incoming connection handled by the current fibril. */
-fibril_local connection_t *FIBRIL_connection;
+static fibril_local connection_t *FIBRIL_connection;
 
 static void *default_client_data_constructor(void)
@@ -199,10 +197,19 @@
 {
 	assert(FIBRIL_connection);
-
 	return FIBRIL_connection->client->data;
 }
 
-static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
-static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call);
+/** Default fibril function that gets called to handle new connection.
+ *
+ * This function is defined as a weak symbol - to be redefined in user code.
+ *
+ * @param callid Hash of the incoming call.
+ * @param call   Data of the incoming call.
+ *
+ */
+static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
+{
+	ipc_answer_0(callid, ENOENT);
+}
 
 /**
@@ -210,4 +217,16 @@
  */
 static async_client_conn_t client_connection = default_client_connection;
+
+/** Default fibril function that gets called to handle interrupt notifications.
+ *
+ * This function is defined as a weak symbol - to be redefined in user code.
+ *
+ * @param callid Hash of the incoming call.
+ * @param call   Data of the incoming call.
+ *
+ */
+static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
+{
+}
 
 /**
@@ -221,17 +240,17 @@
 static LIST_INITIALIZE(timeout_list);
 
-#define CLIENT_HASH_TABLE_BUCKETS	32
-#define CONN_HASH_TABLE_BUCKETS		32
-
-static hash_index_t client_hash(unsigned long *key)
+#define CLIENT_HASH_TABLE_BUCKETS  32
+#define CONN_HASH_TABLE_BUCKETS    32
+
+static hash_index_t client_hash(unsigned long key[])
 {
 	assert(key);
-	return (((*key) >> 4) % CLIENT_HASH_TABLE_BUCKETS); 
+	return (((key[0]) >> 4) % CLIENT_HASH_TABLE_BUCKETS);
 }
 
 static int client_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
-	client_t *cl = hash_table_get_instance(item, client_t, link);
-	return (key[0] == cl->in_task_hash);
+	client_t *client = hash_table_get_instance(item, client_t, link);
+	return (key[0] == client->in_task_hash);
 }
 
@@ -254,8 +273,8 @@
  *
  */
-static hash_index_t conn_hash(unsigned long *key)
+static hash_index_t conn_hash(unsigned long key[])
 {
 	assert(key);
-	return (((*key) >> 4) % CONN_HASH_TABLE_BUCKETS);
+	return (((key[0]) >> 4) % CONN_HASH_TABLE_BUCKETS);
 }
 
@@ -271,21 +290,11 @@
 static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
-	connection_t *hs = hash_table_get_instance(item, connection_t, link);
-	return (key[0] == hs->in_phone_hash);
-}
-
-/** Connection hash table removal callback function.
- *
- * This function is called whenever a connection is removed from the connection
- * hash table.
- *
- * @param item Connection hash table item being removed.
- *
- */
+	connection_t *conn = hash_table_get_instance(item, connection_t, link);
+	return (key[0] == conn->in_phone_hash);
+}
+
 static void conn_remove(link_t *item)
 {
-	free(hash_table_get_instance(item, connection_t, link));
-}
-
+}
 
 /** Operations for the connection hash table. */
@@ -308,9 +317,10 @@
 	link_t *tmp = timeout_list.next;
 	while (tmp != &timeout_list) {
-		awaiter_t *cur;
-		
-		cur = list_get_instance(tmp, awaiter_t, to_event.link);
+		awaiter_t *cur
+		    = list_get_instance(tmp, awaiter_t, to_event.link);
+		
 		if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires))
 			break;
+		
 		tmp = tmp->next;
 	}
@@ -329,5 +339,5 @@
  *
  * @return False if the call doesn't match any connection.
- *         True if the call was passed to the respective connection fibril.
+ * @return True if the call was passed to the respective connection fibril.
  *
  */
@@ -420,4 +430,10 @@
 	
 	fid_t fid = fibril_create(notification_fibril, msg);
+	if (fid == 0) {
+		free(msg);
+		futex_up(&async_futex);
+		return false;
+	}
+	
 	fibril_add_ready(fid);
 	
@@ -466,5 +482,5 @@
 			 * the first IPC_M_PHONE_HUNGUP call and continues to
 			 * call async_get_call_timeout(). Repeat
-			 * IPC_M_PHONE_HUNGUP until the caller notices. 
+			 * IPC_M_PHONE_HUNGUP until the caller notices.
 			 */
 			memset(call, 0, sizeof(ipc_call_t));
@@ -473,5 +489,5 @@
 			return conn->close_callid;
 		}
-
+		
 		if (usecs)
 			async_insert_timeout(&conn->wdata);
@@ -511,29 +527,4 @@
 }
 
-/** Default fibril function that gets called to handle new connection.
- *
- * This function is defined as a weak symbol - to be redefined in user code.
- *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
- *
- */
-static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
-{
-	ipc_answer_0(callid, ENOENT);
-}
-
-/** Default fibril function that gets called to handle interrupt notifications.
- *
- * This function is defined as a weak symbol - to be redefined in user code.
- *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
- *
- */
-static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
-{
-}
-
 /** Wrapper for client connection fibril.
  *
@@ -548,14 +539,11 @@
 static int connection_fibril(void *arg)
 {
-	unsigned long key;
-	client_t *cl;
-	link_t *lnk;
-	bool destroy = false;
-
 	/*
 	 * Setup fibril-local connection pointer.
 	 */
 	FIBRIL_connection = (connection_t *) arg;
-
+	
+	futex_down(&async_futex);
+	
 	/*
 	 * Add our reference for the current connection in the client task
@@ -563,28 +551,35 @@
 	 * hash in a new tracking structure.
 	 */
-	futex_down(&async_futex);
-	key = FIBRIL_connection->in_task_hash;
-	lnk = hash_table_find(&client_hash_table, &key);
+	
+	unsigned long key = FIBRIL_connection->in_task_hash;
+	link_t *lnk = hash_table_find(&client_hash_table, &key);
+	
+	client_t *client;
+	
 	if (lnk) {
-		cl = hash_table_get_instance(lnk, client_t, link);
-		cl->refcnt++;
+		client = hash_table_get_instance(lnk, client_t, link);
+		client->refcnt++;
 	} else {
-		cl = malloc(sizeof(client_t));
-		if (!cl) {
+		client = malloc(sizeof(client_t));
+		if (!client) {
 			ipc_answer_0(FIBRIL_connection->callid, ENOMEM);
 			futex_up(&async_futex);
 			return 0;
 		}
-		cl->in_task_hash = FIBRIL_connection->in_task_hash;
+		
+		client->in_task_hash = FIBRIL_connection->in_task_hash;
+		
 		async_serialize_start();
-		cl->data = async_client_data_create();
+		client->data = async_client_data_create();
 		async_serialize_end();
-		cl->refcnt = 1;
-		hash_table_insert(&client_hash_table, &key, &cl->link);
-	}
+		
+		client->refcnt = 1;
+		hash_table_insert(&client_hash_table, &key, &client->link);
+	}
+	
 	futex_up(&async_futex);
-
-	FIBRIL_connection->client = cl;
-
+	
+	FIBRIL_connection->client = client;
+	
 	/*
 	 * Call the connection handler function.
@@ -596,17 +591,23 @@
 	 * Remove the reference for this client task connection.
 	 */
+	bool destroy;
+	
 	futex_down(&async_futex);
-	if (--cl->refcnt == 0) {
+	
+	if (--client->refcnt == 0) {
 		hash_table_remove(&client_hash_table, &key, 1);
 		destroy = true;
-	}
+	} else
+		destroy = false;
+	
 	futex_up(&async_futex);
-
+	
 	if (destroy) {
-		if (cl->data)
-			async_client_data_destroy(cl->data);
-		free(cl);
-	}
-
+		if (client->data)
+			async_client_data_destroy(client->data);
+		
+		free(client);
+	}
+	
 	/*
 	 * Remove myself from the connection hash table.
@@ -621,8 +622,8 @@
 	 */
 	while (!list_empty(&FIBRIL_connection->msg_queue)) {
-		msg_t *msg;
-		
-		msg = list_get_instance(FIBRIL_connection->msg_queue.next,
-		    msg_t, link);
+		msg_t *msg =
+		    list_get_instance(FIBRIL_connection->msg_queue.next, msg_t,
+		    link);
+		
 		list_remove(&msg->link);
 		ipc_answer_0(msg->callid, EHANGUP);
@@ -637,4 +638,5 @@
 		ipc_answer_0(FIBRIL_connection->close_callid, EOK);
 	
+	free(FIBRIL_connection);
 	return 0;
 }
@@ -667,4 +669,5 @@
 		if (callid)
 			ipc_answer_0(callid, ENOMEM);
+		
 		return (uintptr_t) NULL;
 	}
@@ -684,8 +687,10 @@
 	conn->wdata.fid = fibril_create(connection_fibril, conn);
 	
-	if (!conn->wdata.fid) {
+	if (conn->wdata.fid == 0) {
 		free(conn);
+		
 		if (callid)
 			ipc_answer_0(callid, ENOMEM);
+		
 		return (uintptr_t) NULL;
 	}
@@ -714,8 +719,8 @@
 static void handle_call(ipc_callid_t callid, ipc_call_t *call)
 {
-	/* Unrouted call - do some default behaviour */
+	/* Unrouted call - take some default action */
 	if ((callid & IPC_CALLID_NOTIFICATION)) {
 		process_notification(callid, call);
-		goto out;
+		return;
 	}
 	
@@ -723,20 +728,16 @@
 	case IPC_M_CONNECT_ME:
 	case IPC_M_CONNECT_ME_TO:
-		/* Open new connection with fibril etc. */
+		/* Open new connection with fibril, etc. */
 		async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
 		    callid, call, client_connection);
-		goto out;
+		return;
 	}
 	
 	/* Try to route the call through the connection hash table */
 	if (route_call(callid, call))
-		goto out;
+		return;
 	
 	/* Unknown call from unknown phone - hang it up */
 	ipc_answer_0(callid, EHANGUP);
-	return;
-	
-out:
-	;
 }
 
@@ -751,12 +752,12 @@
 	link_t *cur = timeout_list.next;
 	while (cur != &timeout_list) {
-		awaiter_t *waiter;
-		
-		waiter = list_get_instance(cur, awaiter_t, to_event.link);
+		awaiter_t *waiter =
+		    list_get_instance(cur, awaiter_t, to_event.link);
+		
 		if (tv_gt(&waiter->to_event.expires, &tv))
 			break;
-
+		
 		cur = cur->next;
-
+		
 		list_remove(&waiter->to_event.link);
 		waiter->to_event.inlist = false;
@@ -785,5 +786,5 @@
 	while (true) {
 		if (fibril_switch(FIBRIL_FROM_MANAGER)) {
-			futex_up(&async_futex); 
+			futex_up(&async_futex);
 			/*
 			 * async_futex is always held when entering a manager
@@ -808,11 +809,10 @@
 				continue;
 			} else
-				timeout = tv_sub(&waiter->to_event.expires,
-				    &tv);
+				timeout = tv_sub(&waiter->to_event.expires, &tv);
 		} else
 			timeout = SYNCH_NO_TIMEOUT;
 		
 		futex_up(&async_futex);
-
+		
 		atomic_inc(&threads_in_ipc_wait);
 		
@@ -822,5 +822,5 @@
 		
 		atomic_dec(&threads_in_ipc_wait);
-
+		
 		if (!callid) {
 			handle_expired_timeouts();
@@ -861,5 +861,6 @@
 {
 	fid_t fid = fibril_create(async_manager_fibril, NULL);
-	fibril_add_manager(fid);
+	if (fid != 0)
+		fibril_add_manager(fid);
 }
 
@@ -872,17 +873,14 @@
 /** Initialize the async framework.
  *
- * @return Zero on success or an error code.
- */
-int __async_init(void)
+ */
+void __async_init(void)
 {
 	if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 1,
-	    &client_hash_table_ops) || !hash_table_create(&conn_hash_table,
-	    CONN_HASH_TABLE_BUCKETS, 1, &conn_hash_table_ops)) {
-		return ENOMEM;
-	}
-
-	_async_sess_init();
-	
-	return 0;
+	    &client_hash_table_ops))
+		abort();
+	
+	if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_BUCKETS, 1,
+	    &conn_hash_table_ops))
+		abort();
 }
 
@@ -897,4 +895,5 @@
  * @param retval Value returned in the answer.
  * @param data   Call data of the answer.
+ *
  */
 static void reply_received(void *arg, int retval, ipc_call_t *data)
@@ -944,5 +943,5 @@
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
 {
-	amsg_t *msg = malloc(sizeof(*msg));
+	amsg_t *msg = malloc(sizeof(amsg_t));
 	
 	if (!msg)
@@ -953,5 +952,9 @@
 	
 	msg->wdata.to_event.inlist = false;
-	/* We may sleep in the next method, but it will use its own mechanism */
+	
+	/*
+	 * We may sleep in the next method,
+	 * but it will use its own means
+	 */
 	msg->wdata.active = true;
 	
@@ -984,5 +987,5 @@
     ipc_call_t *dataptr)
 {
-	amsg_t *msg = malloc(sizeof(*msg));
+	amsg_t *msg = malloc(sizeof(amsg_t));
 	
 	if (!msg)
@@ -993,5 +996,9 @@
 	
 	msg->wdata.to_event.inlist = false;
-	/* We may sleep in next method, but it will use its own mechanism */
+	
+	/*
+	 * We may sleep in the next method,
+	 * but it will use its own means
+	 */
 	msg->wdata.active = true;
 	
@@ -1092,5 +1099,5 @@
 void async_usleep(suseconds_t timeout)
 {
-	amsg_t *msg = malloc(sizeof(*msg));
+	amsg_t *msg = malloc(sizeof(amsg_t));
 	
 	if (!msg)
@@ -1235,78 +1242,215 @@
 }
 
+void async_msg_0(int phone, sysarg_t imethod)
+{
+	ipc_call_async_0(phone, imethod, NULL, NULL, true);
+}
+
+void async_msg_1(int phone, sysarg_t imethod, sysarg_t arg1)
+{
+	ipc_call_async_1(phone, imethod, arg1, NULL, NULL, true);
+}
+
+void async_msg_2(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2)
+{
+	ipc_call_async_2(phone, imethod, arg1, arg2, NULL, NULL, true);
+}
+
+void async_msg_3(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3)
+{
+	ipc_call_async_3(phone, imethod, arg1, arg2, arg3, NULL, NULL, true);
+}
+
+void async_msg_4(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, sysarg_t arg4)
+{
+	ipc_call_async_4(phone, imethod, arg1, arg2, arg3, arg4, NULL, NULL,
+	    true);
+}
+
+void async_msg_5(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
+{
+	ipc_call_async_5(phone, imethod, arg1, arg2, arg3, arg4, arg5, NULL,
+	    NULL, true);
+}
+
+sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval)
+{
+	return ipc_answer_0(callid, retval);
+}
+
+sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)
+{
+	return ipc_answer_1(callid, retval, arg1);
+}
+
+sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2)
+{
+	return ipc_answer_2(callid, retval, arg1, arg2);
+}
+
+sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3)
+{
+	return ipc_answer_3(callid, retval, arg1, arg2, arg3);
+}
+
+sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
+{
+	return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4);
+}
+
+sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
+{
+	return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5);
+}
+
+int async_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod,
+    sysarg_t arg1, sysarg_t arg2, unsigned int mode)
+{
+	return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode);
+}
+
+int async_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
+    unsigned int mode)
+{
+	return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4,
+	    arg5, mode);
+}
+
+/** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework.
+ *
+ * Ask through phone for a new connection to some service.
+ *
+ * @param phone           Phone handle used for contacting the other side.
+ * @param arg1            User defined argument.
+ * @param arg2            User defined argument.
+ * @param arg3            User defined argument.
+ * @param client_receiver Connection handing routine.
+ *
+ * @return New phone handle on success or a negative error code.
+ *
+ */
+int async_connect_to_me(int phone, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, async_client_conn_t client_receiver)
+{
+	sysarg_t task_hash;
+	sysarg_t phone_hash;
+	int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
+	    NULL, NULL, NULL, &task_hash, &phone_hash);
+	if (rc != EOK)
+		return rc;
+	
+	if (client_receiver != NULL)
+		async_new_connection(task_hash, phone_hash, 0, NULL,
+		    client_receiver);
+	
+	return EOK;
+}
+
 /** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
- * 
+ *
  * Ask through phone for a new connection to some service.
  *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int
-async_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
-{
-	int rc;
+ * @param phone Phone handle used for contacting the other side.
+ * @param arg1  User defined argument.
+ * @param arg2  User defined argument.
+ * @param arg3  User defined argument.
+ *
+ * @return New phone handle on success or a negative error code.
+ *
+ */
+int async_connect_me_to(int phone, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3)
+{
 	sysarg_t newphid;
-
-	rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL,
-	    NULL, NULL, NULL, &newphid);
-	
-	if (rc != EOK)	
+	int rc = async_req_3_5(phone, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
+	    NULL, NULL, NULL, NULL, &newphid);
+	
+	if (rc != EOK)
 		return rc;
-
+	
 	return newphid;
 }
 
 /** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
- * 
+ *
  * Ask through phone for a new connection to some service and block until
  * success.
  *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int
-async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
+ * @param phoneid Phone handle used for contacting the other side.
+ * @param arg1    User defined argument.
+ * @param arg2    User defined argument.
+ * @param arg3    User defined argument.
+ *
+ * @return New phone handle on success or a negative error code.
+ *
+ */
+int async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
     sysarg_t arg3)
 {
-	int rc;
 	sysarg_t newphid;
-
-	rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
+	int rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
 	    IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
 	
-	if (rc != EOK)	
+	if (rc != EOK)
 		return rc;
-
+	
 	return newphid;
 }
 
-/** Wrapper for making IPC_M_SHARE_IN calls using the async framework.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param dst		Destination address space area base.
- * @param size		Size of the destination address space area.
- * @param arg		User defined argument.
- * @param flags		Storage where the received flags will be stored. Can be
- *			NULL.
- *
- * @return		Zero on success or a negative error code from errno.h.
+/** Connect to a task specified by id.
+ *
+ */
+int async_connect_kbox(task_id_t id)
+{
+	return ipc_connect_kbox(id);
+}
+
+/** Wrapper for ipc_hangup.
+ *
+ * @param phone Phone handle to hung up.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int async_hangup(int phone)
+{
+	return ipc_hangup(phone);
+}
+
+/** Interrupt one thread of this task from waiting for IPC. */
+void async_poke(void)
+{
+	ipc_poke();
+}
+
+/** Wrapper for IPC_M_SHARE_IN calls using the async framework.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param dst     Destination address space area base.
+ * @param size    Size of the destination address space area.
+ * @param arg     User defined argument.
+ * @param flags   Storage for the received flags. Can be NULL.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
  */
 int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
-    int *flags)
-{
-	int res;
+    unsigned int *flags)
+{
 	sysarg_t tmp_flags;
-	res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
+	int res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
 	    (sysarg_t) size, arg, NULL, &tmp_flags);
+	
 	if (flags)
-		*flags = tmp_flags;
+		*flags = (unsigned int) tmp_flags;
+	
 	return res;
 }
@@ -1314,54 +1458,59 @@
 /** Wrapper for receiving the IPC_M_SHARE_IN calls using the async framework.
  *
- * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
+ * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
  *
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid	Storage where the hash of the IPC_M_SHARE_IN call will
- * 			be stored.
- * @param size		Destination address space area size.	
- *
- * @return		Non-zero on success, zero on failure.
- */
-int async_share_in_receive(ipc_callid_t *callid, size_t *size)
-{
-	ipc_call_t data;
-	
+ * @param callid Storage for the hash of the IPC_M_SHARE_IN call.
+ * @param size   Destination address space area size.
+ *
+ * @return True on success, false on failure.
+ *
+ */
+bool async_share_in_receive(ipc_callid_t *callid, size_t *size)
+{
 	assert(callid);
 	assert(size);
-
+	
+	ipc_call_t data;
 	*callid = async_get_call(&data);
+	
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
-		return 0;
+		return false;
+	
 	*size = (size_t) IPC_GET_ARG2(data);
-	return 1;
+	return true;
 }
 
 /** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_READ call to answer.
- * @param src		Source address space base.
- * @param flags		Flags to be used for sharing. Bits can be only cleared.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
- */
-int async_share_in_finalize(ipc_callid_t callid, void *src, int flags)
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_READ call to answer.
+ * @param src    Source address space base.
+ * @param flags  Flags to be used for sharing. Bits can be only cleared.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
+ */
+int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
 {
 	return ipc_share_in_finalize(callid, src, flags);
 }
 
-/** Wrapper for making IPC_M_SHARE_OUT calls using the async framework.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param src		Source address space area base address.
- * @param flags		Flags to be used for sharing. Bits can be only cleared.
- *
- * @return		Zero on success or a negative error code from errno.h.
- */
-int async_share_out_start(int phoneid, void *src, int flags)
+/** Wrapper for IPC_M_SHARE_OUT calls using the async framework.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param src     Source address space area base address.
+ * @param flags   Flags to be used for sharing. Bits can be only cleared.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
+ */
+int async_share_out_start(int phoneid, void *src, unsigned int flags)
 {
 	return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
@@ -1371,42 +1520,45 @@
 /** Wrapper for receiving the IPC_M_SHARE_OUT calls using the async framework.
  *
- * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
+ * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
  *
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid	Storage where the hash of the IPC_M_SHARE_OUT call will
- * 			be stored.
- * @param size		Storage where the source address space area size will be
- *			stored.
- * @param flags		Storage where the sharing flags will be stored.
- *
- * @return		Non-zero on success, zero on failure.
- */
-int async_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags)
-{
-	ipc_call_t data;
-	
+ * @param callid Storage for the hash of the IPC_M_SHARE_OUT call.
+ * @param size   Storage for the source address space area size.
+ * @param flags  Storage for the sharing flags.
+ *
+ * @return True on success, false on failure.
+ *
+ */
+bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags)
+{
 	assert(callid);
 	assert(size);
 	assert(flags);
-
+	
+	ipc_call_t data;
 	*callid = async_get_call(&data);
+	
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
-		return 0;
+		return false;
+	
 	*size = (size_t) IPC_GET_ARG2(data);
-	*flags = (int) IPC_GET_ARG3(data);
-	return 1;
+	*flags = (unsigned int) IPC_GET_ARG3(data);
+	return true;
 }
 
 /** Wrapper for answering the IPC_M_SHARE_OUT calls using the async framework.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_WRITE call to answer.
- * @param dst		Destination address space area base address.	
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
+ * @param dst    Destination address space area base address.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int async_share_out_finalize(ipc_callid_t callid, void *dst)
@@ -1415,12 +1567,12 @@
 }
 
-
-/** Wrapper for making IPC_M_DATA_READ calls using the async framework.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param dst		Address of the beginning of the destination buffer.
- * @param size		Size of the destination buffer.
- *
- * @return		Zero on success or a negative error code from errno.h.
+/** Wrapper for IPC_M_DATA_READ calls using the async framework.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param dst     Address of the beginning of the destination buffer.
+ * @param size    Size of the destination buffer.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
  */
 int async_data_read_start(int phoneid, void *dst, size_t size)
@@ -1432,41 +1584,45 @@
 /** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework.
  *
- * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
+ * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
  *
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid	Storage where the hash of the IPC_M_DATA_READ call will
- * 			be stored.
- * @param size		Storage where the maximum size will be stored. Can be
- *			NULL.
- *
- * @return		Non-zero on success, zero on failure.
- */
-int async_data_read_receive(ipc_callid_t *callid, size_t *size)
-{
+ * @param callid Storage for the hash of the IPC_M_DATA_READ.
+ * @param size   Storage for the maximum size. Can be NULL.
+ *
+ * @return True on success, false on failure.
+ *
+ */
+bool async_data_read_receive(ipc_callid_t *callid, size_t *size)
+{
+	assert(callid);
+	
 	ipc_call_t data;
-	
-	assert(callid);
-
 	*callid = async_get_call(&data);
+	
 	if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ)
-		return 0;
+		return false;
+	
 	if (size)
 		*size = (size_t) IPC_GET_ARG2(data);
-	return 1;
+	
+	return true;
 }
 
 /** Wrapper for answering the IPC_M_DATA_READ calls using the async framework.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_READ call to answer.
- * @param src		Source address for the IPC_M_DATA_READ call.
- * @param size		Size for the IPC_M_DATA_READ call. Can be smaller than
- *			the maximum size announced by the sender.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_READ call to answer.
+ * @param src    Source address for the IPC_M_DATA_READ call.
+ * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
+ *               the maximum size announced by the sender.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
@@ -1476,5 +1632,4 @@
 
 /** Wrapper for forwarding any read request
- *
  *
  */
@@ -1509,5 +1664,5 @@
 }
 
-/** Wrapper for making IPC_M_DATA_WRITE calls using the async framework.
+/** Wrapper for IPC_M_DATA_WRITE calls using the async framework.
  *
  * @param phoneid Phone that will be used to contact the receiving side.
@@ -1526,37 +1681,37 @@
 /** Wrapper for receiving the IPC_M_DATA_WRITE calls using the async framework.
  *
- * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
+ * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
  *
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will
- *               be stored.
- * @param size   Storage where the suggested size will be stored. May be
- *               NULL
- *
- * @return Non-zero on success, zero on failure.
- *
- */
-int async_data_write_receive(ipc_callid_t *callid, size_t *size)
-{
+ * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
+ * @param size   Storage for the suggested size. May be NULL.
+ *
+ * @return True on success, false on failure.
+ *
+ */
+bool async_data_write_receive(ipc_callid_t *callid, size_t *size)
+{
+	assert(callid);
+	
 	ipc_call_t data;
-	
-	assert(callid);
-	
 	*callid = async_get_call(&data);
+	
 	if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE)
-		return 0;
+		return false;
 	
 	if (size)
 		*size = (size_t) IPC_GET_ARG2(data);
 	
-	return 1;
+	return true;
 }
 
 /** Wrapper for answering the IPC_M_DATA_WRITE calls using the async framework.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE
+ * calls so that the user doesn't have to remember the meaning of each IPC
+ * argument.
  *
  * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
@@ -1654,5 +1809,5 @@
  *
  */
-void async_data_write_void(const int retval)
+void async_data_write_void(sysarg_t retval)
 {
 	ipc_callid_t callid;
@@ -1662,5 +1817,4 @@
 
 /** Wrapper for forwarding any data that is about to be received
- *
  *
  */
Index: uspace/lib/c/generic/async_sess.c
===================================================================
--- uspace/lib/c/generic/async_sess.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/async_sess.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -99,5 +99,4 @@
 
 #include <async_sess.h>
-#include <ipc/ipc.h>
 #include <fibril_synch.h>
 #include <adt/list.h>
@@ -106,4 +105,5 @@
 #include <errno.h>
 #include <assert.h>
+#include "private/async_sess.h"
 
 /** An inactive open connection. */
@@ -138,6 +138,7 @@
  *
  * Needs to be called prior to any other interface in this file.
- */
-void _async_sess_init(void)
+ *
+ */
+void __async_sess_init(void)
 {
 	fibril_mutex_initialize(&async_sess_mutex);
@@ -200,5 +201,5 @@
 		list_remove(&conn->global_link);
 		
-		ipc_hangup(conn->data_phone);
+		async_hangup(conn->data_phone);
 		free(conn);
 	}
@@ -260,5 +261,5 @@
 			data_phone = conn->data_phone;
 			free(conn);
-			ipc_hangup(data_phone);
+			async_hangup(data_phone);
 			goto retry;
 		} else {
@@ -292,5 +293,5 @@
 		 * means that we simply hang up.
 		 */
-		ipc_hangup(data_phone);
+		async_hangup(data_phone);
 		fibril_mutex_unlock(&async_sess_mutex);
 		return;
Index: uspace/lib/c/generic/clipboard.c
===================================================================
--- uspace/lib/c/generic/clipboard.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/clipboard.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,4 +39,5 @@
 
 #include <clipboard.h>
+#include <ipc/ns.h>
 #include <ipc/services.h>
 #include <ipc/clipboard.h>
@@ -54,5 +55,5 @@
 {
 	while (clip_phone < 0)
-		clip_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CLIPBOARD, 0, 0);
+		clip_phone = service_connect_blocking(SERVICE_CLIPBOARD, 0, 0);
 }
 
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/ddi.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -127,4 +127,33 @@
 }
 
+/** Register IRQ notification.
+ *
+ * @param inr    IRQ number.
+ * @param devno  Device number of the device generating inr.
+ * @param method Use this method for notifying me.
+ * @param ucode  Top-half pseudocode handler.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int register_irq(int inr, int devno, int method, irq_code_t *ucode)
+{
+	return __SYSCALL4(SYS_REGISTER_IRQ, inr, devno, method,
+	    (sysarg_t) ucode);
+}
+
+/** Unregister IRQ notification.
+ *
+ * @param inr   IRQ number.
+ * @param devno Device number of the device generating inr.
+ *
+ * @return Value returned by the kernel.
+ *
+ */
+int unregister_irq(int inr, int devno)
+{
+	return __SYSCALL2(SYS_UNREGISTER_IRQ, inr, devno);
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/devman.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -28,6 +28,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
- 
- /** @addtogroup libc
+
+/** @addtogroup libc
  * @{
  */
@@ -37,5 +37,4 @@
 #include <str.h>
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/devman.h>
@@ -116,5 +115,5 @@
 	async_set_client_connection(conn);
 	
-	ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);
+	async_connect_to_me(phone, 0, 0, 0, NULL);
 	async_wait_for(req, &retval);
 	
@@ -221,5 +220,5 @@
 	case DEVMAN_DRIVER:
 		if (devman_phone_driver >= 0) {
-			ipc_hangup(devman_phone_driver);
+			async_hangup(devman_phone_driver);
 			devman_phone_driver = -1;
 		}
@@ -227,5 +226,5 @@
 	case DEVMAN_CLIENT:
 		if (devman_phone_client >= 0) {
-			ipc_hangup(devman_phone_client);
+			async_hangup(devman_phone_client);
 			devman_phone_client = -1;
 		}
Index: uspace/lib/c/generic/devmap.c
===================================================================
--- uspace/lib/c/generic/devmap.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/devmap.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -29,6 +29,6 @@
 
 #include <str.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <ipc/devmap.h>
 #include <devmap.h>
@@ -50,9 +50,9 @@
 		
 		if (flags & IPC_FLAG_BLOCKING)
-			devmap_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
-			    SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
+			devmap_phone_driver = service_connect_blocking(SERVICE_DEVMAP,
+			    DEVMAP_DRIVER, 0);
 		else
-			devmap_phone_driver = ipc_connect_me_to(PHONE_NS,
-			    SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
+			devmap_phone_driver = service_connect(SERVICE_DEVMAP,
+			    DEVMAP_DRIVER, 0);
 		
 		return devmap_phone_driver;
@@ -62,9 +62,9 @@
 		
 		if (flags & IPC_FLAG_BLOCKING)
-			devmap_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
-			    SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
+			devmap_phone_client = service_connect_blocking(SERVICE_DEVMAP,
+			    DEVMAP_CLIENT, 0);
 		else
-			devmap_phone_client = ipc_connect_me_to(PHONE_NS,
-			    SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
+			devmap_phone_client = service_connect(SERVICE_DEVMAP,
+			    DEVMAP_CLIENT, 0);
 		
 		return devmap_phone_client;
@@ -79,5 +79,5 @@
 	case DEVMAP_DRIVER:
 		if (devmap_phone_driver >= 0) {
-			ipc_hangup(devmap_phone_driver);
+			async_hangup(devmap_phone_driver);
 			devmap_phone_driver = -1;
 		}
@@ -85,5 +85,5 @@
 	case DEVMAP_CLIENT:
 		if (devmap_phone_client >= 0) {
-			ipc_hangup(devmap_phone_client);
+			async_hangup(devmap_phone_client);
 			devmap_phone_client = -1;
 		}
@@ -116,5 +116,5 @@
 	async_set_client_connection(conn);
 	
-	ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);
+	async_connect_to_me(phone, 0, 0, 0, NULL);
 	async_wait_for(req, &retval);
 	
Index: pace/lib/c/generic/err.c
===================================================================
--- uspace/lib/c/generic/err.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-/* TODO
-void errx(int __status, __const char *__format, ...)
-{
-	_exit(0);
-}
-*/
-
-/** @}
- */
Index: uspace/lib/c/generic/event.c
===================================================================
--- uspace/lib/c/generic/event.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/event.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,10 +35,9 @@
  */
 /** @file
- */ 
+ */
 
 #include <libc.h>
 #include <event.h>
 #include <kernel/ipc/event_types.h>
-#include <ipc/ipc.h>
 
 /** Subscribe for event notifications.
Index: uspace/lib/c/generic/fibril_synch.c
===================================================================
--- uspace/lib/c/generic/fibril_synch.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/fibril_synch.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #include <fibril.h>
 #include <async.h>
-#include <async_priv.h>
 #include <adt/list.h>
 #include <futex.h>
@@ -44,4 +43,5 @@
 #include <stacktrace.h>
 #include <stdlib.h>
+#include "private/async.h"
 
 static void optimize_execution_power(void)
@@ -55,5 +55,5 @@
 	 */
 	if (atomic_get(&threads_in_ipc_wait) > 0)
-		ipc_poke();
+		async_poke();
 }
 
@@ -105,5 +105,5 @@
 
 	if (fibril_get_sercount() != 0)
-		core();
+		abort();
 
 	futex_down(&async_futex);
@@ -198,5 +198,5 @@
 	
 	if (fibril_get_sercount() != 0)
-		core();
+		abort();
 
 	futex_down(&async_futex);
@@ -226,5 +226,5 @@
 	
 	if (fibril_get_sercount() != 0)
-		core();
+		abort();
 
 	futex_down(&async_futex);
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/io/io.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,8 +41,10 @@
 #include <bool.h>
 #include <malloc.h>
+#include <async.h>
 #include <io/klog.h>
 #include <vfs/vfs.h>
 #include <ipc/devmap.h>
 #include <adt/list.h>
+#include "../private/io.h"
 
 static void _ffillbuf(FILE *stream);
@@ -322,5 +324,5 @@
 	
 	if (stream->phone >= 0)
-		ipc_hangup(stream->phone);
+		async_hangup(stream->phone);
 	
 	if (stream->fd >= 0)
Index: uspace/lib/c/generic/ipc.c
===================================================================
--- uspace/lib/c/generic/ipc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/ipc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,21 +45,17 @@
 #include <errno.h>
 #include <adt/list.h>
-#include <stdio.h>
-#include <unistd.h>
 #include <futex.h>
-#include <kernel/synch/synch.h>
-#include <async.h>
 #include <fibril.h>
-#include <assert.h>
 
 /**
- * Structures of this type are used for keeping track of sent asynchronous calls
- * and queing unsent calls.
+ * Structures of this type are used for keeping track
+ * of sent asynchronous calls and queing unsent calls.
  */
 typedef struct {
 	link_t list;
-
+	
 	ipc_async_callback_t callback;
 	void *private;
+	
 	union {
 		ipc_callid_t callid;
@@ -69,5 +65,7 @@
 		} msg;
 	} u;
-	fid_t fid;	/**< Fibril waiting for sending this call. */
+	
+	/** Fibril waiting for sending this call. */
+	fid_t fid;
 } async_call_t;
 
@@ -76,6 +74,7 @@
 /** List of asynchronous calls that were not accepted by kernel.
  *
- * It is protected by async_futex, because if the call cannot be sent into the
- * kernel, the async framework is used automatically.
+ * Protected by async_futex, because if the call is not accepted
+ * by the kernel, the async framework is used automatically.
+ *
  */
 LIST_INITIALIZE(queued_calls);
@@ -83,36 +82,35 @@
 static atomic_t ipc_futex = FUTEX_INITIALIZER;
 
-/** Make a fast synchronous call.
- *
- * Only three payload arguments can be passed using this function. However, this
- * function is faster than the generic ipc_call_sync_slow() because the payload
- * is passed directly in registers.
- *
- * @param phoneid	Phone handle for the call.
- * @param method	Requested method.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param result1	If non-NULL, the return ARG1 will be stored there.
- * @param result2	If non-NULL, the return ARG2 will be stored there.
- * @param result3	If non-NULL, the return ARG3 will be stored there.
- * @param result4	If non-NULL, the return ARG4 will be stored there.
- * @param result5	If non-NULL, the return ARG5 will be stored there.
- *
- * @return		Negative values represent errors returned by IPC.
- *			Otherwise the RETVAL of the answer is returned.
- */
-int
-ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2,
-    sysarg_t arg3, sysarg_t *result1, sysarg_t *result2, sysarg_t *result3,
-    sysarg_t *result4, sysarg_t *result5)
+/** Fast synchronous call.
+ *
+ * Only three payload arguments can be passed using this function. However,
+ * this function is faster than the generic ipc_call_sync_slow() because
+ * the payload is passed directly in registers.
+ *
+ * @param phoneid Phone handle for the call.
+ * @param method  Requested method.
+ * @param arg1    Service-defined payload argument.
+ * @param arg2    Service-defined payload argument.
+ * @param arg3    Service-defined payload argument.
+ * @param result1 If non-NULL, the return ARG1 will be stored there.
+ * @param result2 If non-NULL, the return ARG2 will be stored there.
+ * @param result3 If non-NULL, the return ARG3 will be stored there.
+ * @param result4 If non-NULL, the return ARG4 will be stored there.
+ * @param result5 If non-NULL, the return ARG5 will be stored there.
+ *
+ * @return Negative values representing IPC errors.
+ * @return Otherwise the RETVAL of the answer.
+ *
+ */
+int ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t *result1, sysarg_t *result2,
+    sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
 {
 	ipc_call_t resdata;
-	int callres;
-	
-	callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
+	int callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
 	    arg2, arg3, (sysarg_t) &resdata);
 	if (callres)
 		return callres;
+	
 	if (result1)
 		*result1 = IPC_GET_ARG1(resdata);
@@ -125,9 +123,9 @@
 	if (result5)
 		*result5 = IPC_GET_ARG5(resdata);
-
+	
 	return IPC_GET_RETVAL(resdata);
 }
 
-/** Make a synchronous call transmitting 5 arguments of payload.
+/** Synchronous call transmitting 5 arguments of payload.
  *
  * @param phoneid Phone handle for the call.
@@ -144,12 +142,12 @@
  * @param result5 If non-NULL, storage for the fifth return argument.
  *
- * @return Negative value means IPC error.
- *         Otherwise the RETVAL of the answer.
- *
- */
-int
-ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
-    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1,
-    sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
+ * @return Negative values representing IPC errors.
+ * @return Otherwise the RETVAL of the answer.
+ *
+ */
+int ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
+    sysarg_t *result1, sysarg_t *result2, sysarg_t *result3, sysarg_t *result4,
+    sysarg_t *result5)
 {
 	ipc_call_t data;
@@ -181,5 +179,5 @@
 }
 
-/** Syscall to send asynchronous message.
+/** Send asynchronous message via syscall.
  *
  * @param phoneid Phone handle for the call.
@@ -189,66 +187,72 @@
  *
  */
-static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
+static ipc_callid_t ipc_call_async_internal(int phoneid, ipc_call_t *data)
 {
 	return __SYSCALL2(SYS_IPC_CALL_ASYNC_SLOW, phoneid, (sysarg_t) data);
 }
 
-/** Prolog to ipc_call_async_*() functions.
- *
- * @param private	Argument for the answer/error callback.
- * @param callback	Answer/error callback.
- *
- * @return		New, partially initialized async_call structure or NULL.
+/** Prolog for ipc_call_async_*() functions.
+ *
+ * @param private  Argument for the answer/error callback.
+ * @param callback Answer/error callback.
+ *
+ * @return New, partially initialized async_call structure or NULL.
+ *
  */
 static inline async_call_t *ipc_prepare_async(void *private,
     ipc_async_callback_t callback)
 {
-	async_call_t *call;
-
-	call = malloc(sizeof(*call));
+	async_call_t *call =
+	    (async_call_t *) malloc(sizeof(async_call_t));
 	if (!call) {
 		if (callback)
 			callback(private, ENOMEM, NULL);
+		
 		return NULL;
 	}
+	
 	call->callback = callback;
 	call->private = private;
-
+	
 	return call;
 }
 
-/** Epilogue of ipc_call_async_*() functions.
- *
- * @param callid	Value returned by the SYS_IPC_CALL_ASYNC_* syscall.
- * @param phoneid	Phone handle through which the call was made.
- * @param call		async_call structure returned by ipc_prepare_async().
- * @param can_preempt	If non-zero, the current fibril can be preempted in this
- *			call.
+/** Epilog for ipc_call_async_*() functions.
+ *
+ * @param callid      Value returned by the SYS_IPC_CALL_ASYNC_* syscall.
+ * @param phoneid     Phone handle through which the call was made.
+ * @param call        Structure returned by ipc_prepare_async().
+ * @param can_preempt If true, the current fibril can be preempted
+ *                    in this call.
+ *
  */
 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
-    async_call_t *call, int can_preempt)
-{
-	if (!call) { /* Nothing to do regardless if failed or not */
+    async_call_t *call, bool can_preempt)
+{
+	if (!call) {
+		/* Nothing to do regardless if failed or not */
 		futex_up(&ipc_futex);
 		return;
 	}
-
+	
 	if (callid == (ipc_callid_t) IPC_CALLRET_FATAL) {
 		futex_up(&ipc_futex);
+		
 		/* Call asynchronous handler with error code */
 		if (call->callback)
 			call->callback(call->private, ENOENT, NULL);
+		
 		free(call);
 		return;
 	}
-
+	
 	if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) {
 		futex_up(&ipc_futex);
-
+		
 		call->u.msg.phoneid = phoneid;
 		
 		futex_down(&async_futex);
 		list_append(&call->list, &queued_calls);
-
+		
 		if (can_preempt) {
 			call->fid = fibril_get_id();
@@ -259,14 +263,16 @@
 			futex_up(&async_futex);
 		}
+		
 		return;
 	}
+	
 	call->u.callid = callid;
+	
 	/* Add call to the list of dispatched calls */
 	list_append(&call->list, &dispatched_calls);
 	futex_up(&ipc_futex);
-	
-}
-
-/** Make a fast asynchronous call.
+}
+
+/** Fast asynchronous call.
  *
  * This function can only handle four arguments of payload. It is, however,
@@ -274,7 +280,8 @@
  *
  * Note that this function is a void function.
- * During normal opertation, answering this call will trigger the callback.
- * In case of fatal error, call the callback handler with the proper error code.
- * If the call cannot be temporarily made, queue it.
+ *
+ * During normal operation, answering this call will trigger the callback.
+ * In case of fatal error, the callback handler is called with the proper
+ * error code. If the call cannot be temporarily made, it is queued.
  *
  * @param phoneid     Phone handle for the call.
@@ -286,5 +293,5 @@
  * @param private     Argument to be passed to the answer/error callback.
  * @param callback    Answer or error callback.
- * @param can_preempt If non-zero, the current fibril will be preempted in
+ * @param can_preempt If true, the current fibril will be preempted in
  *                    case the kernel temporarily refuses to accept more
  *                    asynchronous calls.
@@ -293,5 +300,5 @@
 void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private,
-    ipc_async_callback_t callback, int can_preempt)
+    ipc_async_callback_t callback, bool can_preempt)
 {
 	async_call_t *call = NULL;
@@ -304,7 +311,8 @@
 	
 	/*
-	 * We need to make sure that we get callid before another thread
-	 * accesses the queue again.
+	 * We need to make sure that we get callid
+	 * before another thread accesses the queue again.
 	 */
+	
 	futex_down(&ipc_futex);
 	ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,
@@ -317,4 +325,5 @@
 				return;
 		}
+		
 		IPC_SET_IMETHOD(call->u.msg.data, imethod);
 		IPC_SET_ARG1(call->u.msg.data, arg1);
@@ -322,19 +331,23 @@
 		IPC_SET_ARG3(call->u.msg.data, arg3);
 		IPC_SET_ARG4(call->u.msg.data, arg4);
+		
 		/*
 		 * To achieve deterministic behavior, we always zero out the
 		 * arguments that are beyond the limits of the fast version.
 		 */
+		
 		IPC_SET_ARG5(call->u.msg.data, 0);
 	}
+	
 	ipc_finish_async(callid, phoneid, call, can_preempt);
 }
 
-/** Make an asynchronous call transmitting the entire payload.
+/** Asynchronous call transmitting the entire payload.
  *
  * Note that this function is a void function.
- * During normal opertation, answering this call will trigger the callback.
- * In case of fatal error, call the callback handler with the proper error code.
- * If the call cannot be temporarily made, queue it.
+ *
+ * During normal operation, answering this call will trigger the callback.
+ * In case of fatal error, the callback handler is called with the proper
+ * error code. If the call cannot be temporarily made, it is queued.
  *
  * @param phoneid     Phone handle for the call.
@@ -347,5 +360,5 @@
  * @param private     Argument to be passed to the answer/error callback.
  * @param callback    Answer or error callback.
- * @param can_preempt If non-zero, the current fibril will be preempted in
+ * @param can_preempt If true, the current fibril will be preempted in
  *                    case the kernel temporarily refuses to accept more
  *                    asynchronous calls.
@@ -354,13 +367,10 @@
 void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private,
-    ipc_async_callback_t callback, int can_preempt)
-{
-	async_call_t *call;
-	ipc_callid_t callid;
-
-	call = ipc_prepare_async(private, callback);
+    ipc_async_callback_t callback, bool can_preempt)
+{
+	async_call_t *call = ipc_prepare_async(private, callback);
 	if (!call)
 		return;
-
+	
 	IPC_SET_IMETHOD(call->u.msg.data, imethod);
 	IPC_SET_ARG1(call->u.msg.data, arg1);
@@ -369,28 +379,32 @@
 	IPC_SET_ARG4(call->u.msg.data, arg4);
 	IPC_SET_ARG5(call->u.msg.data, arg5);
+	
 	/*
-	 * We need to make sure that we get callid before another thread
-	 * accesses the queue again.
+	 * We need to make sure that we get callid
+	 * before another threadaccesses the queue again.
 	 */
+	
 	futex_down(&ipc_futex);
-	callid = _ipc_call_async(phoneid, &call->u.msg.data);
-
+	ipc_callid_t callid =
+	    ipc_call_async_internal(phoneid, &call->u.msg.data);
+	
 	ipc_finish_async(callid, phoneid, call, can_preempt);
 }
 
-
-/** Answer a received call - fast version.
+/** Answer received call (fast version).
  *
  * The fast answer makes use of passing retval and first four arguments in
  * registers. If you need to return more, use the ipc_answer_slow() instead.
  *
- * @param callid	Hash of the call being answered.
- * @param retval	Return value.
- * @param arg1		First return argument.
- * @param arg2		Second return argument.
- * @param arg3		Third return argument.
- * @param arg4		Fourth return argument.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * @param callid Hash of the call being answered.
+ * @param retval Return value.
+ * @param arg1   First return argument.
+ * @param arg2   Second return argument.
+ * @param arg3   Third return argument.
+ * @param arg4   Fourth return argument.
+ *
+ * @return Zero on success.
+ * @return Value from @ref errno.h on failure.
+ *
  */
 sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
@@ -401,15 +415,17 @@
 }
 
-/** Answer a received call - slow full version.
- *
- * @param callid	Hash of the call being answered.
- * @param retval	Return value.
- * @param arg1		First return argument.
- * @param arg2		Second return argument.
- * @param arg3		Third return argument.
- * @param arg4		Fourth return argument.
- * @param arg5		Fifth return argument.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+/** Answer received call (entire payload).
+ *
+ * @param callid Hash of the call being answered.
+ * @param retval Return value.
+ * @param arg1   First return argument.
+ * @param arg2   Second return argument.
+ * @param arg3   Third return argument.
+ * @param arg4   Fourth return argument.
+ * @param arg5   Fifth return argument.
+ *
+ * @return Zero on success.
+ * @return Value from @ref errno.h on failure.
+ *
  */
 sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
@@ -417,5 +433,5 @@
 {
 	ipc_call_t data;
-
+	
 	IPC_SET_RETVAL(data, retval);
 	IPC_SET_ARG1(data, arg1);
@@ -424,30 +440,33 @@
 	IPC_SET_ARG4(data, arg4);
 	IPC_SET_ARG5(data, arg5);
-
+	
 	return __SYSCALL2(SYS_IPC_ANSWER_SLOW, callid, (sysarg_t) &data);
 }
 
-
-/** Try to dispatch queued calls from the async queue. */
-static void try_dispatch_queued_calls(void)
-{
-	async_call_t *call;
-	ipc_callid_t callid;
-
+/** Try to dispatch queued calls from the async queue.
+ *
+ */
+static void dispatch_queued_calls(void)
+{
 	/** @todo
-	 * Integrate intelligently ipc_futex, so that it is locked during
-	 * ipc_call_async_*(), until it is added to dispatched_calls.
+	 * Integrate intelligently ipc_futex so that it is locked during
+	 * ipc_call_async_*() until it is added to dispatched_calls.
 	 */
+	
 	futex_down(&async_futex);
+	
 	while (!list_empty(&queued_calls)) {
-		call = list_get_instance(queued_calls.next, async_call_t, list);
-		callid = _ipc_call_async(call->u.msg.phoneid,
-		    &call->u.msg.data);
-		if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) {
+		async_call_t *call =
+		    list_get_instance(queued_calls.next, async_call_t, list);
+		ipc_callid_t callid =
+		    ipc_call_async_internal(call->u.msg.phoneid, &call->u.msg.data);
+		
+		if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY)
 			break;
-		}
+		
 		list_remove(&call->list);
-
+		
 		futex_up(&async_futex);
+		
 		if (call->fid)
 			fibril_add_ready(call->fid);
@@ -456,94 +475,114 @@
 			if (call->callback)
 				call->callback(call->private, ENOENT, NULL);
+			
 			free(call);
 		} else {
 			call->u.callid = callid;
+			
 			futex_down(&ipc_futex);
 			list_append(&call->list, &dispatched_calls);
 			futex_up(&ipc_futex);
 		}
+		
 		futex_down(&async_futex);
 	}
+	
 	futex_up(&async_futex);
 }
 
-/** Handle a received answer.
+/** Handle received answer.
  *
  * Find the hash of the answer and call the answer callback.
  *
- * @todo Make it use hash table.
- *
- * @param callid	Hash of the received answer.
- *			The answer has the same hash as the request OR'ed with
- *			the IPC_CALLID_ANSWERED bit.
- * @param data		Call data of the answer.
+ * The answer has the same hash as the request OR'ed with
+ * the IPC_CALLID_ANSWERED bit.
+ *
+ * @todo Use hash table.
+ *
+ * @param callid Hash of the received answer.
+ * @param data   Call data of the answer.
+ *
  */
 static void handle_answer(ipc_callid_t callid, ipc_call_t *data)
 {
+	callid &= ~IPC_CALLID_ANSWERED;
+	
+	futex_down(&ipc_futex);
+	
 	link_t *item;
-	async_call_t *call;
-
-	callid &= ~IPC_CALLID_ANSWERED;
-	
-	futex_down(&ipc_futex);
 	for (item = dispatched_calls.next; item != &dispatched_calls;
 	    item = item->next) {
-		call = list_get_instance(item, async_call_t, list);
+		async_call_t *call =
+		    list_get_instance(item, async_call_t, list);
+		
 		if (call->u.callid == callid) {
 			list_remove(&call->list);
+			
 			futex_up(&ipc_futex);
+			
 			if (call->callback)
-				call->callback(call->private, 
+				call->callback(call->private,
 				    IPC_GET_RETVAL(*data), data);
+			
 			free(call);
 			return;
 		}
 	}
+	
 	futex_up(&ipc_futex);
 }
 
-
-/** Wait for a first call to come.
- *
- * @param call		Storage where the incoming call data will be stored.
- * @param usec		Timeout in microseconds
- * @param flags		Flags passed to SYS_IPC_WAIT (blocking, nonblocking).
- *
- * @return		Hash of the call. Note that certain bits have special
- *			meaning. IPC_CALLID_ANSWERED will be set in an answer
- *			and IPC_CALLID_NOTIFICATION is used for notifications.
- *			
- */
-ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec, int flags)
-{
-	ipc_callid_t callid;
-
-	callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
+/** Wait for first IPC call to come.
+ *
+ * @param call  Incoming call storage.
+ * @param usec  Timeout in microseconds
+ * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking).
+ *
+ * @return Hash of the call. Note that certain bits have special
+ *         meaning: IPC_CALLID_ANSWERED is set in an answer
+ *         and IPC_CALLID_NOTIFICATION is used for notifications.
+ *
+ */
+ipc_callid_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec,
+    unsigned int flags)
+{
+	ipc_callid_t callid =
+	    __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
+	
 	/* Handle received answers */
 	if (callid & IPC_CALLID_ANSWERED) {
 		handle_answer(callid, call);
-		try_dispatch_queued_calls();
+		dispatch_queued_calls();
 	}
-
+	
 	return callid;
 }
 
-/** Wait some time for an IPC call.
- *
- * The call will return after an answer is received.
- *
- * @param call		Storage where the incoming call data will be stored.
- * @param usec		Timeout in microseconds.
- *
- * @return		Hash of the answer.
- */
-ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec)
+/** Interrupt one thread of this task from waiting for IPC.
+ *
+ */
+void ipc_poke(void)
+{
+	__SYSCALL0(SYS_IPC_POKE);
+}
+
+/** Wait for first IPC call to come.
+ *
+ * Only requests are returned, answers are processed internally.
+ *
+ * @param call Incoming call storage.
+ * @param usec Timeout in microseconds
+ *
+ * @return Hash of the call.
+ *
+ */
+ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec)
 {
 	ipc_callid_t callid;
-
+	
 	do {
 		callid = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE);
 	} while (callid & IPC_CALLID_ANSWERED);
-
+	
 	return callid;
 }
@@ -551,41 +590,40 @@
 /** Check if there is an IPC call waiting to be picked up.
  *
- * @param call		Storage where the incoming call will be stored.
- * @return		Hash of the answer.
+ * Only requests are returned, answers are processed internally.
+ *
+ * @param call Incoming call storage.
+ *
+ * @return Hash of the call.
+ *
  */
 ipc_callid_t ipc_trywait_for_call(ipc_call_t *call)
 {
 	ipc_callid_t callid;
-
+	
 	do {
 		callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT,
 		    SYNCH_FLAGS_NON_BLOCKING);
 	} while (callid & IPC_CALLID_ANSWERED);
-
+	
 	return callid;
 }
 
-/** Interrupt one thread of this task from waiting for IPC. */
-void ipc_poke(void)
-{
-	__SYSCALL0(SYS_IPC_POKE);
-}
-
-/** Ask destination to do a callback connection.
- *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		Service-defined argument.
- * @param arg2		Service-defined argument.
- * @param arg3		Service-defined argument.
- * @param taskhash	Storage where the kernel will store an opaque
- *			identifier of the client task.
- * @param phonehash	Storage where the kernel will store an opaque
- *			identifier of the phone that will be used for incoming
- *			calls. This identifier can be used for connection
- *			tracking.
- *
- * @return		Zero on success or a negative error code.
- */
-int ipc_connect_to_me(int phoneid, int arg1, int arg2, int arg3, 
+/** Request callback connection.
+ *
+ * The @a taskhash and @a phonehash identifiers returned
+ * by the kernel can be used for connection tracking.
+ *
+ * @param phoneid   Phone handle used for contacting the other side.
+ * @param arg1      User defined argument.
+ * @param arg2      User defined argument.
+ * @param arg3      User defined argument.
+ * @param taskhash  Opaque identifier of the client task.
+ * @param phonehash Opaque identifier of the phone that will
+ *                  be used for incoming calls.
+ *
+ * @return Zero on success or a negative error code.
+ *
+ */
+int ipc_connect_to_me(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
     sysarg_t *taskhash, sysarg_t *phonehash)
 {
@@ -594,46 +632,48 @@
 }
 
-/** Ask through phone for a new connection to some service.
- *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3)
+/** Request new connection.
+ *
+ * @param phoneid Phone handle used for contacting the other side.
+ * @param arg1    User defined argument.
+ * @param arg2    User defined argument.
+ * @param arg3    User defined argument.
+ *
+ * @return New phone handle on success or a negative error code.
+ *
+ */
+int ipc_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
 {
 	sysarg_t newphid;
-	int res;
-
-	res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
+	int res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
 	    NULL, NULL, NULL, NULL, &newphid);
 	if (res)
 		return res;
+	
 	return newphid;
 }
 
-/** Ask through phone for a new connection to some service.
+/** Request new connection (blocking)
  *
  * If the connection is not available at the moment, the
- * call will block.
- *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3)
+ * call should block. This has to be, however, implemented
+ * on the server side.
+ *
+ * @param phoneid Phone handle used for contacting the other side.
+ * @param arg1    User defined argument.
+ * @param arg2    User defined argument.
+ * @param arg3    User defined argument.
+ *
+ * @return New phone handle on success or a negative error code.
+ *
+ */
+int ipc_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3)
 {
 	sysarg_t newphid;
-	int res;
-
-	res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
+	int res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
 	    IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
 	if (res)
 		return res;
+	
 	return newphid;
 }
@@ -641,7 +681,8 @@
 /** Hang up a phone.
  *
- * @param phoneid	Handle of the phone to be hung up.
- *
- * @return		Zero on success or a negative error code.
+ * @param phoneid Handle of the phone to be hung up.
+ *
+ * @return Zero on success or a negative error code.
+ *
  */
 int ipc_hangup(int phoneid)
@@ -650,32 +691,10 @@
 }
 
-/** Register IRQ notification.
- *
- * @param inr		IRQ number.
- * @param devno		Device number of the device generating inr.
- * @param method	Use this method for notifying me.
- * @param ucode		Top-half pseudocode handler.
- *
- * @return		Value returned by the kernel.
- */
-int ipc_register_irq(int inr, int devno, int method, irq_code_t *ucode)
-{
-	return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method,
-	    (sysarg_t) ucode);
-}
-
-/** Unregister IRQ notification.
- *
- * @param inr		IRQ number.
- * @param devno		Device number of the device generating inr.
- *
- * @return		Value returned by the kernel.
- */
-int ipc_unregister_irq(int inr, int devno)
-{
-	return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno);
-}
-
 /** Forward a received call to another destination.
+ *
+ * For non-system methods, the old method, arg1 and arg2 are rewritten
+ * by the new values. For system methods, the new method, arg1 and arg2
+ * are written to the old arg1, arg2 and arg3, respectivelly. Calls with
+ * immutable methods are forwarded verbatim.
  *
  * @param callid  Hash of the call to forward.
@@ -688,11 +707,7 @@
  * @return Zero on success or an error code.
  *
- * For non-system methods, the old method, arg1 and arg2 are rewritten by the
- * new values. For system methods, the new method, arg1 and arg2 are written 
- * to the old arg1, arg2 and arg3, respectivelly. Calls with immutable 
- * methods are forwarded verbatim.
- */
-int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
-    sysarg_t arg1, sysarg_t arg2, int mode)
+ */
+int ipc_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod,
+    sysarg_t arg1, sysarg_t arg2, unsigned int mode)
 {
 	return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1,
@@ -700,8 +715,7 @@
 }
 
-
-int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
+int ipc_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod,
     sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
-    int mode)
+    unsigned int mode)
 {
 	ipc_call_t data;
@@ -714,20 +728,21 @@
 	IPC_SET_ARG5(data, arg5);
 	
-	return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode);
-}
-
-/** Wrapper for making IPC_M_SHARE_IN calls.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param dst		Destination address space area base.
- * @param size		Size of the destination address space area.
- * @param arg		User defined argument.
- * @param flags		Storage where the received flags will be stored. Can be
- *			NULL.
- *
- * @return		Zero on success or a negative error code from errno.h.
+	return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data,
+	    mode);
+}
+
+/** Wrapper for IPC_M_SHARE_IN calls.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param dst     Destination address space area base.
+ * @param size    Size of the destination address space area.
+ * @param arg     User defined argument.
+ * @param flags   Storage for received flags. Can be NULL.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
  */
 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
-    int *flags)
+    unsigned int *flags)
 {
 	sysarg_t tmp_flags = 0;
@@ -736,5 +751,5 @@
 	
 	if (flags)
-		*flags = tmp_flags;
+		*flags = (unsigned int) tmp_flags;
 	
 	return res;
@@ -743,27 +758,30 @@
 /** Wrapper for answering the IPC_M_SHARE_IN calls.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_READ call to answer.
- * @param src		Source address space base.
- * @param flags		Flags to be used for sharing. Bits can be only cleared.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
- */
-int ipc_share_in_finalize(ipc_callid_t callid, void *src, int flags)
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
+ * calls so that the user doesn't have to remember the meaning of each
+ * IPC argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_READ call to answer.
+ * @param src    Source address space base.
+ * @param flags Flags to be used for sharing. Bits can be only cleared.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
+ */
+int ipc_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
 {
 	return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags);
 }
 
-/** Wrapper for making IPC_M_SHARE_OUT calls.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param src		Source address space area base address.
- * @param flags		Flags to be used for sharing. Bits can be only cleared.
- *
- * @return		Zero on success or a negative error code from errno.h.
- */
-int ipc_share_out_start(int phoneid, void *src, int flags)
+/** Wrapper for IPC_M_SHARE_OUT calls.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param src     Source address space area base address.
+ * @param flags   Flags to be used for sharing. Bits can be only cleared.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
+ */
+int ipc_share_out_start(int phoneid, void *src, unsigned int flags)
 {
 	return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
@@ -773,11 +791,13 @@
 /** Wrapper for answering the IPC_M_SHARE_OUT calls.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_WRITE call to answer.
- * @param dst		Destination address space area base address.	
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT
+ * calls so that the user doesn't have to remember the meaning of each
+ * IPC argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
+ * @param dst    Destination address space area base address.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int ipc_share_out_finalize(ipc_callid_t callid, void *dst)
@@ -786,12 +806,12 @@
 }
 
-
-/** Wrapper for making IPC_M_DATA_READ calls.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param dst		Address of the beginning of the destination buffer.
- * @param size		Size of the destination buffer.
- *
- * @return		Zero on success or a negative error code from errno.h.
+/** Wrapper for IPC_M_DATA_READ calls.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param dst     Address of the beginning of the destination buffer.
+ * @param size    Size of the destination buffer.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
  */
 int ipc_data_read_start(int phoneid, void *dst, size_t size)
@@ -803,13 +823,15 @@
 /** Wrapper for answering the IPC_M_DATA_READ calls.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_READ call to answer.
- * @param src		Source address for the IPC_M_DATA_READ call.
- * @param size		Size for the IPC_M_DATA_READ call. Can be smaller than
- *			the maximum size announced by the sender.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
+ * calls so that the user doesn't have to remember the meaning of each
+ * IPC argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_READ call to answer.
+ * @param src    Source address for the IPC_M_DATA_READ call.
+ * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
+ *               the maximum size announced by the sender.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
@@ -818,11 +840,12 @@
 }
 
-/** Wrapper for making IPC_M_DATA_WRITE calls.
- *
- * @param phoneid	Phone that will be used to contact the receiving side.
- * @param src		Address of the beginning of the source buffer.
- * @param size		Size of the source buffer.
- *
- * @return		Zero on success or a negative error code from errno.h.
+/** Wrapper for IPC_M_DATA_WRITE calls.
+ *
+ * @param phoneid Phone that will be used to contact the receiving side.
+ * @param src     Address of the beginning of the source buffer.
+ * @param size    Size of the source buffer.
+ *
+ * @return Zero on success or a negative error code from errno.h.
+ *
  */
 int ipc_data_write_start(int phoneid, const void *src, size_t size)
@@ -834,12 +857,14 @@
 /** Wrapper for answering the IPC_M_DATA_WRITE calls.
  *
- * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls
- * so that the user doesn't have to remember the meaning of each IPC argument.
- *
- * @param callid	Hash of the IPC_M_DATA_WRITE call to answer.
- * @param dst		Final destination address for the IPC_M_DATA_WRITE call.
- * @param size		Final size for the IPC_M_DATA_WRITE call.
- *
- * @return		Zero on success or a value from @ref errno.h on failure.
+ * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE
+ * calls so that the user doesn't have to remember the meaning of each
+ * IPC argument.
+ *
+ * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
+ * @param dst    Final destination address for the IPC_M_DATA_WRITE call.
+ * @param size   Final size for the IPC_M_DATA_WRITE call.
+ *
+ * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
Index: uspace/lib/c/generic/ipc/ns.c
===================================================================
--- uspace/lib/c/generic/ipc/ns.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/ipc/ns.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <async.h>
+#include <ipc/ns.h>
+
+int service_register(sysarg_t service)
+{
+	return async_connect_to_me(PHONE_NS, service, 0, 0, NULL);
+}
+
+int service_connect(sysarg_t service, sysarg_t arg2, sysarg_t arg3)
+{
+	return async_connect_me_to(PHONE_NS, service, arg2, arg3);
+}
+
+int service_connect_blocking(sysarg_t service, sysarg_t arg2, sysarg_t arg3)
+{
+	return async_connect_me_to_blocking(PHONE_NS, service, arg2, arg3);
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/libc.c
===================================================================
--- uspace/lib/c/generic/libc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/libc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,28 +42,28 @@
 
 #include <libc.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <tls.h>
-#include <thread.h>
 #include <fibril.h>
-#include <ipc/ipc.h>
-#include <async.h>
-#include <as.h>
+#include <task.h>
 #include <loader/pcb.h>
+#include "private/libc.h"
+#include "private/async.h"
+#include "private/async_sess.h"
+#include "private/malloc.h"
+#include "private/io.h"
 
-extern int main(int argc, char *argv[]);
-
-void _exit(int status)
-{
-	thread_exit(status);
-}
+static bool env_setup = false;
 
 void __main(void *pcb_ptr)
 {
 	/* Initialize user task run-time environment */
-	__heap_init();
+	__malloc_init();
 	__async_init();
+	__async_sess_init();
+	
 	fibril_t *fibril = fibril_setup();
+	if (fibril == NULL)
+		abort();
+	
 	__tcb_set(fibril->tcb);
 	
@@ -71,9 +71,14 @@
 	__pcb = (pcb_t *) pcb_ptr;
 	
+	/* The basic run-time environment is setup */
+	env_setup = true;
+	
 	int argc;
 	char **argv;
 	
-	/* Get command line arguments and initialize
-	   standard input and output */
+	/*
+	 * Get command line arguments and initialize
+	 * standard input and output
+	 */
 	if (__pcb == NULL) {
 		argc = 0;
@@ -87,14 +92,32 @@
 	}
 	
-	/* Run main() and set task return value
-	   according the result */
-	(void) task_retval(main(argc, argv));
+	/*
+	 * Run main() and set task return value
+	 * according the result
+	 */
+	int retval = main(argc, argv);
+	exit(retval);
 }
 
-void __exit(void)
+void exit(int status)
 {
-	__stdio_done();
-	fibril_teardown(__tcb_get()->fibril_data);
-	_exit(0);
+	if (env_setup) {
+		__stdio_done();
+		task_retval(status);
+		fibril_teardown(__tcb_get()->fibril_data);
+	}
+	
+	__SYSCALL1(SYS_TASK_EXIT, false);
+	
+	/* Unreachable */
+	while (1);
+}
+
+void abort(void)
+{
+	__SYSCALL1(SYS_TASK_EXIT, true);
+	
+	/* Unreachable */
+	while (1);
 }
 
Index: uspace/lib/c/generic/loader.c
===================================================================
--- uspace/lib/c/generic/loader.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/loader.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,7 +33,7 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/loader.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <libc.h>
 #include <task.h>
@@ -63,5 +63,5 @@
 loader_t *loader_connect(void)
 {
-	int phone_id = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0);
+	int phone_id = service_connect_blocking(SERVICE_LOAD, 0, 0);
 	if (phone_id < 0)
 		return NULL;
@@ -319,5 +319,5 @@
 		return rc;
 	
-	ipc_hangup(ldr->phone_id);
+	async_hangup(ldr->phone_id);
 	ldr->phone_id = 0;
 	return EOK;
@@ -337,5 +337,5 @@
 void loader_abort(loader_t *ldr)
 {
-	ipc_hangup(ldr->phone_id);
+	async_hangup(ldr->phone_id);
 	ldr->phone_id = 0;
 }
Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/malloc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,34 +45,79 @@
 #include <futex.h>
 #include <adt/gcdlcm.h>
-
-/* Magic used in heap headers. */
-#define HEAP_BLOCK_HEAD_MAGIC  0xBEEF0101
-
-/* Magic used in heap footers. */
-#define HEAP_BLOCK_FOOT_MAGIC  0xBEEF0202
-
-/** Allocation alignment (this also covers the alignment of fields
-    in the heap header and footer) */
+#include "private/malloc.h"
+
+/** Magic used in heap headers. */
+#define HEAP_BLOCK_HEAD_MAGIC  UINT32_C(0xBEEF0101)
+
+/** Magic used in heap footers. */
+#define HEAP_BLOCK_FOOT_MAGIC  UINT32_C(0xBEEF0202)
+
+/** Magic used in heap descriptor. */
+#define HEAP_AREA_MAGIC  UINT32_C(0xBEEFCAFE)
+
+/** Allocation alignment.
+ *
+ * This also covers the alignment of fields
+ * in the heap header and footer.
+ *
+ */
 #define BASE_ALIGN  16
 
-/**
- * Either 4 * 256M on 32-bit architecures or 16 * 256M on 64-bit architectures
- */
-#define MAX_HEAP_SIZE  (sizeof(uintptr_t) << 28)
-
-/**
- *
- */
-#define STRUCT_OVERHEAD  (sizeof(heap_block_head_t) + sizeof(heap_block_foot_t))
-
-/**
- * Calculate real size of a heap block (with header and footer)
+/** Overhead of each heap block. */
+#define STRUCT_OVERHEAD \
+	(sizeof(heap_block_head_t) + sizeof(heap_block_foot_t))
+
+/** Calculate real size of a heap block.
+ *
+ * Add header and footer size.
+ *
  */
 #define GROSS_SIZE(size)  ((size) + STRUCT_OVERHEAD)
 
-/**
- * Calculate net size of a heap block (without header and footer)
+/** Calculate net size of a heap block.
+ *
+ * Subtract header and footer size.
+ *
  */
 #define NET_SIZE(size)  ((size) - STRUCT_OVERHEAD)
+
+/** Get first block in heap area.
+ *
+ */
+#define AREA_FIRST_BLOCK(area) \
+	(ALIGN_UP(((uintptr_t) (area)) + sizeof(heap_area_t), BASE_ALIGN))
+
+/** Get footer in heap block.
+ *
+ */
+#define BLOCK_FOOT(head) \
+	((heap_block_foot_t *) \
+	    (((uintptr_t) head) + head->size - sizeof(heap_block_foot_t)))
+
+/** Heap area.
+ *
+ * The memory managed by the heap allocator is divided into
+ * multiple discontinuous heaps. Each heap is represented
+ * by a separate address space area which has this structure
+ * at its very beginning.
+ *
+ */
+typedef struct heap_area {
+	/** Start of the heap area (including this structure)
+	 *
+	 * Aligned on page boundary.
+	 *
+	 */
+	void *start;
+	
+	/** End of the heap area (aligned on page boundary) */
+	void *end;
+	
+	/** Next heap area */
+	struct heap_area *next;
+	
+	/** A magic value */
+	uint32_t magic;
+} heap_area_t;
 
 /** Header of a heap block
@@ -86,4 +131,7 @@
 	bool free;
 	
+	/** Heap area this block belongs to */
+	heap_area_t *area;
+	
 	/* A magic value to detect overwrite of heap header */
 	uint32_t magic;
@@ -101,25 +149,19 @@
 } heap_block_foot_t;
 
-/** Linker heap symbol */
-extern char _heap;
+/** First heap area */
+static heap_area_t *first_heap_area = NULL;
+
+/** Last heap area */
+static heap_area_t *last_heap_area = NULL;
+
+/** Next heap block to examine (next fit algorithm) */
+static heap_block_head_t *next = NULL;
 
 /** Futex for thread-safe heap manipulation */
 static futex_t malloc_futex = FUTEX_INITIALIZER;
 
-/** Address of heap start */
-static void *heap_start = 0;
-
-/** Address of heap end */
-static void *heap_end = 0;
-
-/** Maximum heap size */
-static size_t max_heap_size = (size_t) -1;
-
-/** Current number of pages of heap area */
-static size_t heap_pages = 0;
-
 /** Initialize a heap block
  *
- * Fills in the structures related to a heap block.
+ * Fill in the structures related to a heap block.
  * Should be called only inside the critical section.
  *
@@ -127,16 +169,18 @@
  * @param size Size of the block including the header and the footer.
  * @param free Indication of a free block.
- *
- */
-static void block_init(void *addr, size_t size, bool free)
+ * @param area Heap area the block belongs to.
+ *
+ */
+static void block_init(void *addr, size_t size, bool free, heap_area_t *area)
 {
 	/* Calculate the position of the header and the footer */
 	heap_block_head_t *head = (heap_block_head_t *) addr;
-	heap_block_foot_t *foot =
-	    (heap_block_foot_t *) (addr + size - sizeof(heap_block_foot_t));
 	
 	head->size = size;
 	head->free = free;
+	head->area = area;
 	head->magic = HEAP_BLOCK_HEAD_MAGIC;
+	
+	heap_block_foot_t *foot = BLOCK_FOOT(head);
 	
 	foot->size = size;
@@ -159,6 +203,5 @@
 	assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);
 	
-	heap_block_foot_t *foot =
-	    (heap_block_foot_t *) (addr + head->size - sizeof(heap_block_foot_t));
+	heap_block_foot_t *foot = BLOCK_FOOT(head);
 	
 	assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);
@@ -166,92 +209,143 @@
 }
 
-/** Increase the heap area size
- *
- * Should be called only inside the critical section.
- *
- * @param size Number of bytes to grow the heap by.
- *
- */
-static bool grow_heap(size_t size)
+/** Check a heap area structure
+ *
+ * @param addr Address of the heap area.
+ *
+ */
+static void area_check(void *addr)
+{
+	heap_area_t *area = (heap_area_t *) addr;
+	
+	assert(area->magic == HEAP_AREA_MAGIC);
+	assert(area->start < area->end);
+	assert(((uintptr_t) area->start % PAGE_SIZE) == 0);
+	assert(((uintptr_t) area->end % PAGE_SIZE) == 0);
+}
+
+/** Create new heap area
+ *
+ * @param start Preffered starting address of the new area.
+ * @param size  Size of the area.
+ *
+ */
+static bool area_create(size_t size)
+{
+	void *start = as_get_mappable_page(size);
+	if (start == NULL)
+		return false;
+	
+	/* Align the heap area on page boundary */
+	void *astart = (void *) ALIGN_UP((uintptr_t) start, PAGE_SIZE);
+	size_t asize = ALIGN_UP(size, PAGE_SIZE);
+	
+	astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ);
+	if (astart == (void *) -1)
+		return false;
+	
+	heap_area_t *area = (heap_area_t *) astart;
+	
+	area->start = astart;
+	area->end = (void *)
+	    ALIGN_DOWN((uintptr_t) astart + asize, BASE_ALIGN);
+	area->next = NULL;
+	area->magic = HEAP_AREA_MAGIC;
+	
+	void *block = (void *) AREA_FIRST_BLOCK(area);
+	size_t bsize = (size_t) (area->end - block);
+	
+	block_init(block, bsize, true, area);
+	
+	if (last_heap_area == NULL) {
+		first_heap_area = area;
+		last_heap_area = area;
+	} else {
+		last_heap_area->next = area;
+		last_heap_area = area;
+	}
+	
+	return true;
+}
+
+/** Try to enlarge a heap area
+ *
+ * @param area Heap area to grow.
+ * @param size Gross size of item to allocate (bytes).
+ *
+ */
+static bool area_grow(heap_area_t *area, size_t size)
 {
 	if (size == 0)
+		return true;
+	
+	area_check(area);
+	
+	size_t asize = ALIGN_UP((size_t) (area->end - area->start) + size,
+	    PAGE_SIZE);
+	
+	/* New heap area size */
+	void *end = (void *)
+	    ALIGN_DOWN((uintptr_t) area->start + asize, BASE_ALIGN);
+	
+	/* Check for overflow */
+	if (end < area->start)
 		return false;
-
-	if ((heap_start + size < heap_start) || (heap_end + size < heap_end))
+	
+	/* Resize the address space area */
+	int ret = as_area_resize(area->start, asize, 0);
+	if (ret != EOK)
 		return false;
 	
-	size_t heap_size = (size_t) (heap_end - heap_start);
-	
-	if ((max_heap_size != (size_t) -1) && (heap_size + size > max_heap_size))
-		return false;
-	
-	size_t pages = (size - 1) / PAGE_SIZE + 1;
-	
-	if (as_area_resize((void *) &_heap, (heap_pages + pages) * PAGE_SIZE, 0)
-	    == EOK) {
-		void *end = (void *) ALIGN_DOWN(((uintptr_t) &_heap) +
-		    (heap_pages + pages) * PAGE_SIZE, BASE_ALIGN);
-		block_init(heap_end, end - heap_end, true);
-		heap_pages += pages;
-		heap_end = end;
+	/* Add new free block */
+	block_init(area->end, (size_t) (end - area->end), true, area);
+	
+	/* Update heap area parameters */
+	area->end = end;
+	
+	return true;
+}
+
+/** Try to enlarge any of the heap areas
+ *
+ * @param size Gross size of item to allocate (bytes).
+ *
+ */
+static bool heap_grow(size_t size)
+{
+	if (size == 0)
 		return true;
-	}
-	
-	return false;
-}
-
-/** Decrease the heap area
- *
- * Should be called only inside the critical section.
- *
- * @param size Number of bytes to shrink the heap by.
- *
- */
-static void shrink_heap(void)
-{
-	// TODO
+	
+	/* First try to enlarge some existing area */
+	heap_area_t *area;
+	for (area = first_heap_area; area != NULL; area = area->next) {
+		if (area_grow(area, size))
+			return true;
+	}
+	
+	/* Eventually try to create a new area */
+	return area_create(AREA_FIRST_BLOCK(size));
+}
+
+/** Try to shrink heap space
+ *
+ * In all cases the next pointer is reset.
+ *
+ */
+static void heap_shrink(void)
+{
+	next = NULL;
 }
 
 /** Initialize the heap allocator
  *
- * Find how much physical memory we have and create
- * the heap management structures that mark the whole
- * physical memory as a single free block.
- *
- */
-void __heap_init(void)
-{
-	futex_down(&malloc_futex);
-	
-	if (as_area_create((void *) &_heap, PAGE_SIZE,
-	    AS_AREA_WRITE | AS_AREA_READ)) {
-		heap_pages = 1;
-		heap_start = (void *) ALIGN_UP((uintptr_t) &_heap, BASE_ALIGN);
-		heap_end =
-		    (void *) ALIGN_DOWN(((uintptr_t) &_heap) + PAGE_SIZE, BASE_ALIGN);
-		
-		/* Make the entire area one large block. */
-		block_init(heap_start, heap_end - heap_start, true);
-	}
-	
-	futex_up(&malloc_futex);
-}
-
-/** Get maximum heap address
- *
- */
-uintptr_t get_max_heap_addr(void)
-{
-	futex_down(&malloc_futex);
-	
-	if (max_heap_size == (size_t) -1)
-		max_heap_size =
-		    max((size_t) (heap_end - heap_start), MAX_HEAP_SIZE);
-	
-	uintptr_t max_heap_addr = (uintptr_t) heap_start + max_heap_size;
-	
-	futex_up(&malloc_futex);
-	
-	return max_heap_addr;
+ * Create initial heap memory area. This routine is
+ * only called from libc initialization, thus we do not
+ * take any locks.
+ *
+ */
+void __malloc_init(void)
+{
+	if (!area_create(PAGE_SIZE))
+		abort();
 }
 
@@ -275,6 +369,6 @@
 		/* Block big enough -> split. */
 		void *next = ((void *) cur) + size;
-		block_init(next, cur->size - size, true);
-		block_init(cur, size, false);
+		block_init(next, cur->size - size, true, cur->area);
+		block_init(cur, size, false, cur->area);
 	} else {
 		/* Block too small -> use as is. */
@@ -283,43 +377,53 @@
 }
 
-/** Allocate a memory block
+/** Allocate memory from heap area starting from given block
  *
  * Should be called only inside the critical section.
- *
- * @param size  The size of the block to allocate.
- * @param align Memory address alignment.
- *
- * @return the address of the block or NULL when not enough memory.
- *
- */
-static void *malloc_internal(const size_t size, const size_t align)
-{
-	if (align == 0)
-		return NULL;
-	
-	size_t falign = lcm(align, BASE_ALIGN);
-	size_t real_size = GROSS_SIZE(ALIGN_UP(size, falign));
-	
-	bool grown = false;
-	void *result;
-	
-loop:
-	result = NULL;
-	heap_block_head_t *cur = (heap_block_head_t *) heap_start;
-	
-	while ((result == NULL) && ((void *) cur < heap_end)) {
+ * As a side effect this function also sets the current
+ * pointer on successful allocation.
+ *
+ * @param area        Heap area where to allocate from.
+ * @param first_block Starting heap block.
+ * @param final_block Heap block where to finish the search
+ *                    (may be NULL).
+ * @param real_size   Gross number of bytes to allocate.
+ * @param falign      Physical alignment of the block.
+ *
+ * @return Address of the allocated block or NULL on not enough memory.
+ *
+ */
+static void *malloc_area(heap_area_t *area, heap_block_head_t *first_block,
+    heap_block_head_t *final_block, size_t real_size, size_t falign)
+{
+	area_check((void *) area);
+	assert((void *) first_block >= (void *) AREA_FIRST_BLOCK(area));
+	assert((void *) first_block < area->end);
+	
+	heap_block_head_t *cur;
+	for (cur = first_block; (void *) cur < area->end;
+	    cur = (heap_block_head_t *) (((void *) cur) + cur->size)) {
 		block_check(cur);
+		
+		/* Finish searching on the final block */
+		if ((final_block != NULL) && (cur == final_block))
+			break;
 		
 		/* Try to find a block that is free and large enough. */
 		if ((cur->free) && (cur->size >= real_size)) {
-			/* We have found a suitable block.
-			   Check for alignment properties. */
-			void *addr = ((void *) cur) + sizeof(heap_block_head_t);
-			void *aligned = (void *) ALIGN_UP(addr, falign);
+			/*
+			 * We have found a suitable block.
+			 * Check for alignment properties.
+			 */
+			void *addr = (void *)
+			    ((uintptr_t) cur + sizeof(heap_block_head_t));
+			void *aligned = (void *)
+			    ALIGN_UP((uintptr_t) addr, falign);
 			
 			if (addr == aligned) {
 				/* Exact block start including alignment. */
 				split_mark(cur, real_size);
-				result = addr;
+				
+				next = cur;
+				return addr;
 			} else {
 				/* Block start has to be aligned */
@@ -327,15 +431,19 @@
 				
 				if (cur->size >= real_size + excess) {
-					/* The current block is large enough to fit
-					   data in including alignment */
-					if ((void *) cur > heap_start) {
-						/* There is a block before the current block.
-						   This previous block can be enlarged to compensate
-						   for the alignment excess */
-						heap_block_foot_t *prev_foot =
-						    ((void *) cur) - sizeof(heap_block_foot_t);
+					/*
+					 * The current block is large enough to fit
+					 * data in (including alignment).
+					 */
+					if ((void *) cur > (void *) AREA_FIRST_BLOCK(area)) {
+						/*
+						 * There is a block before the current block.
+						 * This previous block can be enlarged to
+						 * compensate for the alignment excess.
+						 */
+						heap_block_foot_t *prev_foot = (heap_block_foot_t *)
+						    ((void *) cur - sizeof(heap_block_foot_t));
 						
-						heap_block_head_t *prev_head =
-						    (heap_block_head_t *) (((void *) cur) - prev_foot->size);
+						heap_block_head_t *prev_head = (heap_block_head_t *)
+						    ((void *) cur - prev_foot->size);
 						
 						block_check(prev_head);
@@ -344,25 +452,38 @@
 						heap_block_head_t *next_head = ((void *) cur) + excess;
 						
-						if ((!prev_head->free) && (excess >= STRUCT_OVERHEAD)) {
-							/* The previous block is not free and there is enough
-							   space to fill in a new free block between the previous
-							   and current block */
-							block_init(cur, excess, true);
+						if ((!prev_head->free) &&
+						    (excess >= STRUCT_OVERHEAD)) {
+							/*
+							 * The previous block is not free and there
+							 * is enough free space left to fill in
+							 * a new free block between the previous
+							 * and current block.
+							 */
+							block_init(cur, excess, true, area);
 						} else {
-							/* The previous block is free (thus there is no need to
-							   induce additional fragmentation to the heap) or the
-							   excess is small, thus just enlarge the previous block */
-							block_init(prev_head, prev_head->size + excess, prev_head->free);
+							/*
+							 * The previous block is free (thus there
+							 * is no need to induce additional
+							 * fragmentation to the heap) or the
+							 * excess is small. Therefore just enlarge
+							 * the previous block.
+							 */
+							block_init(prev_head, prev_head->size + excess,
+							    prev_head->free, area);
 						}
 						
-						block_init(next_head, reduced_size, true);
+						block_init(next_head, reduced_size, true, area);
 						split_mark(next_head, real_size);
-						result = aligned;
-						cur = next_head;
+						
+						next = next_head;
+						return aligned;
 					} else {
-						/* The current block is the first block on the heap.
-						   We have to make sure that the alignment excess
-						   is large enough to fit a new free block just
-						   before the current block */
+						/*
+						 * The current block is the first block
+						 * in the heap area. We have to make sure
+						 * that the alignment excess is large enough
+						 * to fit a new free block just before the
+						 * current block.
+						 */
 						while (excess < STRUCT_OVERHEAD) {
 							aligned += falign;
@@ -373,10 +494,14 @@
 						if (cur->size >= real_size + excess) {
 							size_t reduced_size = cur->size - excess;
-							cur = (heap_block_head_t *) (heap_start + excess);
+							cur = (heap_block_head_t *)
+							    (AREA_FIRST_BLOCK(area) + excess);
 							
-							block_init(heap_start, excess, true);
-							block_init(cur, reduced_size, true);
+							block_init((void *) AREA_FIRST_BLOCK(area), excess,
+							    true, area);
+							block_init(cur, reduced_size, true, area);
 							split_mark(cur, real_size);
-							result = aligned;
+							
+							next = cur;
+							return aligned;
 						}
 					}
@@ -384,17 +509,67 @@
 			}
 		}
-		
-		/* Advance to the next block. */
-		cur = (heap_block_head_t *) (((void *) cur) + cur->size);
-	}
-	
-	if ((result == NULL) && (!grown)) {
-		if (grow_heap(real_size)) {
-			grown = true;
+	}
+	
+	return NULL;
+}
+
+/** Allocate a memory block
+ *
+ * Should be called only inside the critical section.
+ *
+ * @param size  The size of the block to allocate.
+ * @param align Memory address alignment.
+ *
+ * @return Address of the allocated block or NULL on not enough memory.
+ *
+ */
+static void *malloc_internal(const size_t size, const size_t align)
+{
+	assert(first_heap_area != NULL);
+	
+	if (align == 0)
+		return NULL;
+	
+	size_t falign = lcm(align, BASE_ALIGN);
+	size_t real_size = GROSS_SIZE(ALIGN_UP(size, falign));
+	
+	bool retry = false;
+	heap_block_head_t *split;
+	
+loop:
+	
+	/* Try the next fit approach */
+	split = next;
+	
+	if (split != NULL) {
+		void *addr = malloc_area(split->area, split, NULL, real_size,
+		    falign);
+		
+		if (addr != NULL)
+			return addr;
+	}
+	
+	/* Search the entire heap */
+	heap_area_t *area;
+	for (area = first_heap_area; area != NULL; area = area->next) {
+		heap_block_head_t *first = (heap_block_head_t *)
+		    AREA_FIRST_BLOCK(area);
+		
+		void *addr = malloc_area(area, first, split, real_size,
+		    falign);
+		
+		if (addr != NULL)
+			return addr;
+	}
+	
+	if (!retry) {
+		/* Try to grow the heap space */
+		if (heap_grow(real_size)) {
+			retry = true;
 			goto loop;
 		}
 	}
 	
-	return result;
+	return NULL;
 }
 
@@ -475,9 +650,12 @@
 	    (heap_block_head_t *) (addr - sizeof(heap_block_head_t));
 	
-	assert((void *) head >= heap_start);
-	assert((void *) head < heap_end);
-	
 	block_check(head);
 	assert(!head->free);
+	
+	heap_area_t *area = head->area;
+	
+	area_check(area);
+	assert((void *) head >= (void *) AREA_FIRST_BLOCK(area));
+	assert((void *) head < area->end);
 	
 	void *ptr = NULL;
@@ -489,29 +667,34 @@
 		/* Shrink */
 		if (orig_size - real_size >= STRUCT_OVERHEAD) {
-			/* Split the original block to a full block
-			   and a trailing free block */
-			block_init((void *) head, real_size, false);
+			/*
+			 * Split the original block to a full block
+			 * and a trailing free block.
+			 */
+			block_init((void *) head, real_size, false, area);
 			block_init((void *) head + real_size,
-			    orig_size - real_size, true);
-			shrink_heap();
+			    orig_size - real_size, true, area);
+			heap_shrink();
 		}
 		
 		ptr = ((void *) head) + sizeof(heap_block_head_t);
 	} else {
-		/* Look at the next block. If it is free and the size is
-		   sufficient then merge the two. Otherwise just allocate
-		   a new block, copy the original data into it and
-		   free the original block. */
+		/*
+		 * Look at the next block. If it is free and the size is
+		 * sufficient then merge the two. Otherwise just allocate
+		 * a new block, copy the original data into it and
+		 * free the original block.
+		 */
 		heap_block_head_t *next_head =
 		    (heap_block_head_t *) (((void *) head) + head->size);
 		
-		if (((void *) next_head < heap_end) &&
+		if (((void *) next_head < area->end) &&
 		    (head->size + next_head->size >= real_size) &&
 		    (next_head->free)) {
 			block_check(next_head);
-			block_init(head, head->size + next_head->size, false);
+			block_init(head, head->size + next_head->size, false, area);
 			split_mark(head, real_size);
 			
 			ptr = ((void *) head) + sizeof(heap_block_head_t);
+			next = NULL;
 		} else
 			reloc = true;
@@ -544,9 +727,12 @@
 	    = (heap_block_head_t *) (addr - sizeof(heap_block_head_t));
 	
-	assert((void *) head >= heap_start);
-	assert((void *) head < heap_end);
-	
 	block_check(head);
 	assert(!head->free);
+	
+	heap_area_t *area = head->area;
+	
+	area_check(area);
+	assert((void *) head >= (void *) AREA_FIRST_BLOCK(area));
+	assert((void *) head < area->end);
 	
 	/* Mark the block itself as free. */
@@ -557,12 +743,12 @@
 	    = (heap_block_head_t *) (((void *) head) + head->size);
 	
-	if ((void *) next_head < heap_end) {
+	if ((void *) next_head < area->end) {
 		block_check(next_head);
 		if (next_head->free)
-			block_init(head, head->size + next_head->size, true);
+			block_init(head, head->size + next_head->size, true, area);
 	}
 	
 	/* Look at the previous block. If it is free, merge the two. */
-	if ((void *) head > heap_start) {
+	if ((void *) head > (void *) AREA_FIRST_BLOCK(area)) {
 		heap_block_foot_t *prev_foot =
 		    (heap_block_foot_t *) (((void *) head) - sizeof(heap_block_foot_t));
@@ -574,8 +760,9 @@
 		
 		if (prev_head->free)
-			block_init(prev_head, prev_head->size + head->size, true);
-	}
-	
-	shrink_heap();
+			block_init(prev_head, prev_head->size + head->size, true,
+			    area);
+	}
+	
+	heap_shrink();
 	
 	futex_up(&malloc_futex);
Index: uspace/lib/c/generic/net/icmp_api.c
===================================================================
--- uspace/lib/c/generic/net/icmp_api.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/net/icmp_api.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,11 +41,8 @@
 #include <net/modules.h>
 #include <net/ip_codes.h>
-
 #include <async.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <errno.h>
-
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/icmp.h>
Index: uspace/lib/c/generic/net/modules.c
===================================================================
--- uspace/lib/c/generic/net/modules.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/net/modules.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,8 +43,5 @@
 #include <errno.h>
 #include <sys/time.h>
-
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <net/modules.h>
 
@@ -67,21 +64,21 @@
 		switch (count) {
 		case 0:
-			ipc_answer_0(callid, (sysarg_t) result);
+			async_answer_0(callid, (sysarg_t) result);
 			break;
 		case 1:
-			ipc_answer_1(callid, (sysarg_t) result,
+			async_answer_1(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer));
 			break;
 		case 2:
-			ipc_answer_2(callid, (sysarg_t) result,
+			async_answer_2(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer));
 			break;
 		case 3:
-			ipc_answer_3(callid, (sysarg_t) result,
+			async_answer_3(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer));
 			break;
 		case 4:
-			ipc_answer_4(callid, (sysarg_t) result,
+			async_answer_4(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer));
@@ -89,5 +86,5 @@
 		case 5:
 		default:
-			ipc_answer_5(callid, (sysarg_t) result,
+			async_answer_5(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer),
@@ -137,21 +134,13 @@
     sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
 {
-	int rc;
-	
 	/* Connect to the needed service */
 	int phone = connect_to_service_timeout(need, timeout);
 	if (phone >= 0) {
 		/* Request the bidirectional connection */
-		sysarg_t taskhash;
-		sysarg_t phonehash;
-		
-		rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &taskhash,
-		    &phonehash);
+		int rc = async_connect_to_me(phone, arg1, arg2, arg3, client_receiver);
 		if (rc != EOK) {
-			ipc_hangup(phone);
+			async_hangup(phone);
 			return rc;
 		}
-		async_new_connection(taskhash, phonehash, 0, NULL,
-		    client_receiver);
 	}
 	
Index: uspace/lib/c/generic/net/socket_client.c
===================================================================
--- uspace/lib/c/generic/net/socket_client.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/net/socket_client.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,8 +43,7 @@
 #include <stdlib.h>
 #include <errno.h>
-
+#include <task.h>
 #include <ipc/services.h>
 #include <ipc/socket.h>
-
 #include <net/modules.h>
 #include <net/in.h>
@@ -278,5 +277,5 @@
 	}
 
-	ipc_answer_0(callid, (sysarg_t) rc);
+	async_answer_0(callid, (sysarg_t) rc);
 	goto loop;
 }
@@ -687,5 +686,5 @@
 
 	/* Read address */
-	ipc_data_read_start(socket->phone, cliaddr, *addrlen);
+	async_data_read_start(socket->phone, cliaddr, *addrlen);
 	fibril_rwlock_write_unlock(&socket_globals.lock);
 	async_wait_for(message_id, &ipc_result);
Index: uspace/lib/c/generic/private/async.h
===================================================================
--- uspace/lib/c/generic/private/async.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/async.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_ASYNC_H_
+#define LIBC_PRIVATE_ASYNC_H_
+
+#include <adt/list.h>
+#include <fibril.h>
+#include <sys/time.h>
+#include <bool.h>
+
+/** Structures of this type are used to track the timeout events. */
+typedef struct {
+	/** If true, this struct is in the timeout list. */
+	bool inlist;
+	
+	/** Timeout list link. */
+	link_t link;
+	
+	/** If true, we have timed out. */
+	bool occurred;
+	
+	/** Expiration time. */
+	struct timeval expires;
+} to_event_t;
+
+/** Structures of this type are used to track the wakeup events. */
+typedef struct {
+	/** If true, this struct is in a synchronization object wait queue. */
+	bool inlist;
+	
+	/** Wait queue linkage. */
+	link_t link;
+} wu_event_t;
+
+/** Structures of this type represent a waiting fibril. */
+typedef struct {
+	/** Identification of and link to the waiting fibril. */
+	fid_t fid;
+	
+	/** If true, this fibril is currently active. */
+	bool active;
+	
+	/** Timeout wait data. */
+	to_event_t to_event;
+	/** Wakeup wait data. */
+	wu_event_t wu_event;
+} awaiter_t;
+
+extern void __async_init(void);
+extern void async_insert_timeout(awaiter_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/private/async_sess.h
===================================================================
--- uspace/lib/c/generic/private/async_sess.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/async_sess.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_ASYNC_SESS_H_
+#define LIBC_PRIVATE_ASYNC_SESS_H_
+
+extern void __async_sess_init(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/private/io.h
===================================================================
--- uspace/lib/c/generic/private/io.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/io.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_IO_H_
+#define LIBC_PRIVATE_IO_H_
+
+#include <vfs/vfs.h>
+
+extern void __stdio_init(int filc, fdi_node_t *filv[]);
+extern void __stdio_done(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/private/libc.h
===================================================================
--- uspace/lib/c/generic/private/libc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/libc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_LIBC_H_
+#define LIBC_PRIVATE_LIBC_H_
+
+extern void __entry(void);
+extern void __main(void *) __attribute__((noreturn));
+extern int main(int, char *[]);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/private/malloc.h
===================================================================
--- uspace/lib/c/generic/private/malloc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/malloc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_MALLOC_H_
+#define LIBC_PRIVATE_MALLOC_H_
+
+extern void __malloc_init(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/private/thread.h
===================================================================
--- uspace/lib/c/generic/private/thread.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/generic/private/thread.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_PRIVATE_THREAD_H_
+#define LIBC_PRIVATE_THREAD_H_
+
+#include <kernel/proc/uarg.h>
+
+extern void __thread_entry(void);
+extern void __thread_main(uspace_arg_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/thread.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,5 +31,5 @@
  */
 /** @file
- */ 
+ */
 
 #include <thread.h>
@@ -41,4 +41,5 @@
 #include <str.h>
 #include <async.h>
+#include "private/thread.h"
 
 #ifndef THREAD_INITIAL_STACK_PAGES_NO
@@ -50,25 +51,27 @@
  * This function is called from __thread_entry() and is used
  * to call the thread's implementing function and perform cleanup
- * and exit when thread returns back. Do not call this function
- * directly.
+ * and exit when thread returns back.
  *
  * @param uarg Pointer to userspace argument structure.
+ *
  */
 void __thread_main(uspace_arg_t *uarg)
 {
-	fibril_t *f;
-
-	f = fibril_setup();
-	__tcb_set(f->tcb);
-
+	fibril_t *fibril = fibril_setup();
+	if (fibril == NULL)
+		thread_exit(0);
+	
+	__tcb_set(fibril->tcb);
+	
 	uarg->uspace_thread_function(uarg->uspace_thread_arg);
-	/* XXX: we cannot free the userspace stack while running on it */
-//	free(uarg->uspace_stack);
-//	free(uarg);
-
+	/* XXX: we cannot free the userspace stack while running on it
+		free(uarg->uspace_stack);
+		free(uarg);
+	*/
+	
 	/* If there is a manager, destroy it */
 	async_destroy_manager();
-	fibril_teardown(f);
-
+	fibril_teardown(fibril);
+	
 	thread_exit(0);
 }
@@ -127,10 +130,12 @@
  *
  * @param status Exit status. Currently not used.
+ *
  */
 void thread_exit(int status)
 {
 	__SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status);
-	for (;;)
-		;
+	
+	/* Unreachable */
+	while (1);
 }
 
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/time.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,21 +34,15 @@
 
 #include <sys/time.h>
-#include <unistd.h>
-#include <ipc/ipc.h>
-#include <stdio.h>
+#include <time.h>
+#include <bool.h>
 #include <arch/barrier.h>
-#include <unistd.h>
-#include <atomic.h>
-#include <sysinfo.h>
-#include <ipc/services.h>
-#include <libc.h>
-
+#include <macros.h>
+#include <errno.h>
 #include <sysinfo.h>
 #include <as.h>
 #include <ddi.h>
-
-#include <time.h>
-
-/* Pointers to public variables with time */
+#include <libc.h>
+
+/** Pointer to kernel shared variables with time */
 struct {
 	volatile sysarg_t seconds1;
@@ -59,6 +53,7 @@
 /** Add microseconds to given timeval.
  *
- * @param tv		Destination timeval.
- * @param usecs		Number of microseconds to add.
+ * @param tv    Destination timeval.
+ * @param usecs Number of microseconds to add.
+ *
  */
 void tv_add(struct timeval *tv, suseconds_t usecs)
@@ -66,4 +61,5 @@
 	tv->tv_sec += usecs / 1000000;
 	tv->tv_usec += usecs % 1000000;
+	
 	if (tv->tv_usec > 1000000) {
 		tv->tv_sec++;
@@ -74,104 +70,117 @@
 /** Subtract two timevals.
  *
- * @param tv1		First timeval.
- * @param tv2		Second timeval.
- *
- * @return		Return difference between tv1 and tv2 (tv1 - tv2) in
- * 			microseconds.
+ * @param tv1 First timeval.
+ * @param tv2 Second timeval.
+ *
+ * @return Difference between tv1 and tv2 (tv1 - tv2) in
+ *         microseconds.
+ *
  */
 suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2)
 {
-	suseconds_t result;
-
-	result = tv1->tv_usec - tv2->tv_usec;
-	result += (tv1->tv_sec - tv2->tv_sec) * 1000000;
-
-	return result;
+	return (tv1->tv_usec - tv2->tv_usec) +
+	    ((tv1->tv_sec - tv2->tv_sec) * 1000000);
 }
 
 /** Decide if one timeval is greater than the other.
  *
- * @param t1		First timeval.
- * @param t2		Second timeval.
- *
- * @return		Return true tv1 is greater than tv2. Otherwise return
- * 			false.
+ * @param t1 First timeval.
+ * @param t2 Second timeval.
+ *
+ * @return True if tv1 is greater than tv2.
+ * @return False otherwise.
+ *
  */
 int tv_gt(struct timeval *tv1, struct timeval *tv2)
 {
 	if (tv1->tv_sec > tv2->tv_sec)
-		return 1;
-	if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec > tv2->tv_usec)
-		return 1;
-	return 0;
+		return true;
+	
+	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec > tv2->tv_usec))
+		return true;
+	
+	return false;
 }
 
 /** Decide if one timeval is greater than or equal to the other.
  *
- * @param tv1		First timeval.
- * @param tv2		Second timeval.
- *
- * @return		Return true if tv1 is greater than or equal to tv2.
- * 			Otherwise return false.
+ * @param tv1 First timeval.
+ * @param tv2 Second timeval.
+ *
+ * @return True if tv1 is greater than or equal to tv2.
+ * @return False otherwise.
+ *
  */
 int tv_gteq(struct timeval *tv1, struct timeval *tv2)
 {
 	if (tv1->tv_sec > tv2->tv_sec)
-		return 1;
-	if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec >= tv2->tv_usec)
-		return 1;
-	return 0;
-}
-
-
-/** POSIX gettimeofday
- *
- * The time variables are memory mapped(RO) from kernel, which updates
- * them periodically. As it is impossible to read 2 values atomically, we
- * use a trick: First read a seconds, then read microseconds, then
- * read seconds again. If a second elapsed in the meantime, set it to zero. 
- * This provides assurance, that at least the
- * sequence of subsequent gettimeofday calls is ordered.
+		return true;
+	
+	if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec >= tv2->tv_usec))
+		return true;
+	
+	return false;
+}
+
+/** Get time of day
+ *
+ * The time variables are memory mapped (read-only) from kernel which
+ * updates them periodically.
+ *
+ * As it is impossible to read 2 values atomically, we use a trick:
+ * First we read the seconds, then we read the microseconds, then we
+ * read the seconds again. If a second elapsed in the meantime, set
+ * the microseconds to zero.
+ *
+ * This assures that the values returned by two subsequent calls
+ * to gettimeofday() are monotonous.
+ *
  */
 int gettimeofday(struct timeval *tv, struct timezone *tz)
 {
-	void *mapping;
-	sysarg_t s1, s2;
-	int rights;
-	int res;
-
-	if (!ktime) {
-		mapping = as_get_mappable_page(PAGE_SIZE);
-		/* Get the mapping of kernel clock */
-		res = ipc_share_in_start_1_1(PHONE_NS, mapping, PAGE_SIZE,
-		    SERVICE_MEM_REALTIME, &rights);
-		if (res) {
-			printf("Failed to initialize timeofday memarea\n");
-			_exit(1);
+	if (ktime == NULL) {
+		uintptr_t faddr;
+		int rc = sysinfo_get_value("clock.faddr", &faddr);
+		if (rc != EOK) {
+			errno = rc;
+			return -1;
 		}
-		if (!(rights & AS_AREA_READ)) {
-			printf("Received bad rights on time area: %X\n",
-			    rights);
-			as_area_destroy(mapping);
-			_exit(1);
+		
+		void *addr = as_get_mappable_page(PAGE_SIZE);
+		if (addr == NULL) {
+			errno = ENOMEM;
+			return -1;
 		}
-		ktime = mapping;
-	}
+		
+		rc = physmem_map((void *) faddr, addr, 1,
+		    AS_AREA_READ | AS_AREA_CACHEABLE);
+		if (rc != EOK) {
+			as_area_destroy(addr);
+			errno = rc;
+			return -1;
+		}
+		
+		ktime = addr;
+	}
+	
 	if (tz) {
 		tz->tz_minuteswest = 0;
 		tz->tz_dsttime = DST_NONE;
 	}
-
-	s2 = ktime->seconds2;
+	
+	sysarg_t s2 = ktime->seconds2;
+	
 	read_barrier();
 	tv->tv_usec = ktime->useconds;
+	
 	read_barrier();
-	s1 = ktime->seconds1;
+	sysarg_t s1 = ktime->seconds1;
+	
 	if (s1 != s2) {
+		tv->tv_sec = max(s1, s2);
 		tv->tv_usec = 0;
-		tv->tv_sec = s1 > s2 ? s1 : s2;
 	} else
 		tv->tv_sec = s1;
-
+	
 	return 0;
 }
@@ -180,13 +189,16 @@
 {
 	struct timeval tv;
-
 	if (gettimeofday(&tv, NULL))
 		return (time_t) -1;
+	
 	if (tloc)
 		*tloc = tv.tv_sec;
+	
 	return tv.tv_sec;
 }
 
-/** Wait unconditionally for specified number of microseconds */
+/** Wait unconditionally for specified number of microseconds
+ *
+ */
 int usleep(useconds_t usec)
 {
@@ -195,15 +207,21 @@
 }
 
-/** Wait unconditionally for specified number of seconds */
+/** Wait unconditionally for specified number of seconds
+ *
+ */
 unsigned int sleep(unsigned int sec)
 {
-	/* Sleep in 1000 second steps to support
-	   full argument range */
+	/*
+	 * Sleep in 1000 second steps to support
+	 * full argument range
+	 */
+	
 	while (sec > 0) {
 		unsigned int period = (sec > 1000) ? 1000 : sec;
-	
+		
 		usleep(period * 1000000);
 		sec -= period;
 	}
+	
 	return 0;
 }
Index: uspace/lib/c/generic/udebug.c
===================================================================
--- uspace/lib/c/generic/udebug.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/udebug.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,9 +31,8 @@
  */
 /** @file
- */ 
+ */
 
 #include <udebug.h>
 #include <sys/types.h>
-#include <ipc/ipc.h>
 #include <async.h>
 
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2008 Jakub Jermar 
+ * Copyright (c) 2008 Jakub Jermar
  * All rights reserved.
  *
@@ -43,6 +43,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <async.h>
 #include <fibril_synch.h>
@@ -118,8 +118,6 @@
 static void vfs_connect(void)
 {
-	while (vfs_phone < 0) {
-		vfs_phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_VFS,
-		    0, 0);
-	}
+	while (vfs_phone < 0)
+		vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
 	
 	async_session_create(&vfs_session, vfs_phone, 0);
Index: uspace/lib/c/include/as.h
===================================================================
--- uspace/lib/c/include/as.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/as.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,4 +41,17 @@
 #include <libarch/config.h>
 
+static inline size_t SIZE2PAGES(size_t size)
+{
+	if (size == 0)
+		return 0;
+	
+	return (size_t) ((size - 1) >> PAGE_WIDTH) + 1;
+}
+
+static inline size_t PAGES2SIZE(size_t pages)
+{
+	return (size_t) (pages << PAGE_WIDTH);
+}
+
 extern void *as_area_create(void *address, size_t size, int flags);
 extern int as_area_resize(void *address, size_t size, int flags);
Index: uspace/lib/c/include/assert.h
===================================================================
--- uspace/lib/c/include/assert.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/assert.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -57,6 +57,4 @@
 			printf("Assertion failed (%s) at file '%s', " \
 			    "line %d.\n", #expr, __FILE__, __LINE__); \
-			stacktrace_print(); \
-			core(); \
 			abort(); \
 		} \
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/async.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,8 +33,12 @@
  */
 
+#if ((defined(LIBC_IPC_H_)) && (!defined(LIBC_ASYNC_C_)))
+	#error Do not intermix low-level IPC interface and async framework
+#endif
+
 #ifndef LIBC_ASYNC_H_
 #define LIBC_ASYNC_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 #include <async_sess.h>
 #include <fibril.h>
@@ -42,4 +46,5 @@
 #include <atomic.h>
 #include <bool.h>
+#include <task.h>
 
 typedef ipc_callid_t aid_t;
@@ -50,20 +55,13 @@
 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
 
-extern atomic_t async_futex;
-
 extern atomic_t threads_in_ipc_wait;
 
-extern int __async_init(void);
+#define async_manager() \
+	fibril_switch(FIBRIL_TO_MANAGER)
+
+#define async_get_call(data) \
+	async_get_call_timeout(data, 0)
+
 extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
-
-static inline ipc_callid_t async_get_call(ipc_call_t *data)
-{
-	return async_get_call_timeout(data, 0);
-}
-
-static inline void async_manager(void)
-{
-	fibril_switch(FIBRIL_TO_MANAGER);
-}
 
 /*
@@ -110,22 +108,38 @@
 extern void async_set_interrupt_received(async_client_conn_t);
 
-/* Wrappers for simple communication */
-#define async_msg_0(phone, method) \
-	ipc_call_async_0((phone), (method), NULL, NULL, true)
-#define async_msg_1(phone, method, arg1) \
-	ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \
-	    true)
-#define async_msg_2(phone, method, arg1, arg2) \
-	ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \
-	    true)
-#define async_msg_3(phone, method, arg1, arg2, arg3) \
-	ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \
-	    true)
-#define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \
-	ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
-	    NULL, true)
-#define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \
-	ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \
-	    (arg5), NULL, NULL, true)
+/*
+ * Wrappers for simple communication.
+ */
+
+extern void async_msg_0(int, sysarg_t);
+extern void async_msg_1(int, sysarg_t, sysarg_t);
+extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
+extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
+extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
+extern void async_msg_5(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t);
+
+/*
+ * Wrappers for answer routines.
+ */
+
+extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
+extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
+extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
+extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t);
+extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t);
+extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t);
+
+/*
+ * Wrappers for forwarding routines.
+ */
+
+extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
+    unsigned int);
+extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, unsigned int);
 
 /*
@@ -135,4 +149,5 @@
  * and slow verion based on m.
  */
+
 #define async_req_0_0(phoneid, method) \
 	async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
@@ -266,10 +281,16 @@
 }
 
+extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
+    async_client_conn_t);
 extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
 extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
+extern int async_connect_kbox(task_id_t);
+extern int async_hangup(int);
+extern void async_poke(void);
 
 /*
  * User-friendly wrappers for async_share_in_start().
  */
+
 #define async_share_in_start_0_0(phoneid, dst, size) \
 	async_share_in_start((phoneid), (dst), (size), 0, NULL)
@@ -281,9 +302,10 @@
 	async_share_in_start((phoneid), (dst), (size), (arg), (flags))
 
-extern int async_share_in_start(int, void *, size_t, sysarg_t, int *);
-extern int async_share_in_receive(ipc_callid_t *, size_t *);
-extern int async_share_in_finalize(ipc_callid_t, void *, int );
-extern int async_share_out_start(int, void *, int);
-extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
+extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
+extern bool async_share_in_receive(ipc_callid_t *, size_t *);
+extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
+
+extern int async_share_out_start(int, void *, unsigned int);
+extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
 extern int async_share_out_finalize(ipc_callid_t, void *);
 
@@ -291,4 +313,5 @@
  * User-friendly wrappers for async_data_read_forward_fast().
  */
+
 #define async_data_read_forward_0_0(phoneid, method, answer) \
 	async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
@@ -318,5 +341,5 @@
 
 extern int async_data_read_start(int, void *, size_t);
-extern int async_data_read_receive(ipc_callid_t *, size_t *);
+extern bool async_data_read_receive(ipc_callid_t *, size_t *);
 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
 
@@ -327,4 +350,5 @@
  * User-friendly wrappers for async_data_write_forward_fast().
  */
+
 #define async_data_write_forward_0_0(phoneid, method, answer) \
 	async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
@@ -356,10 +380,10 @@
 
 extern int async_data_write_start(int, const void *, size_t);
-extern int async_data_write_receive(ipc_callid_t *, size_t *);
+extern bool async_data_write_receive(ipc_callid_t *, size_t *);
 extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
 
 extern int async_data_write_accept(void **, const bool, const size_t,
     const size_t, const size_t, size_t *);
-extern void async_data_write_void(const int);
+extern void async_data_write_void(sysarg_t);
 
 extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
Index: pace/lib/c/include/async_priv.h
===================================================================
--- uspace/lib/c/include/async_priv.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/*
- * Copyright (c) 2006 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_ASYNC_PRIV_H_
-#define LIBC_ASYNC_PRIV_H_
-
-#include <adt/list.h>
-#include <fibril.h>
-#include <sys/time.h>
-#include <bool.h>
-
-/** Structures of this type are used to track the timeout events. */
-typedef struct {
-	/** If true, this struct is in the timeout list. */
-	bool inlist;
-	
-	/** Timeout list link. */
-	link_t link;
-	
-	/** If true, we have timed out. */
-	bool occurred;
-
-	/** Expiration time. */
-	struct timeval expires;
-} to_event_t;
-
-/** Structures of this type are used to track the wakeup events. */
-typedef struct {
-	/** If true, this struct is in a synchronization object wait queue. */
-	bool inlist;
-	
-	/** Wait queue linkage. */
-	link_t link;
-} wu_event_t;
-
-
-/** Structures of this type represent a waiting fibril. */
-typedef struct {
-	/** Identification of and link to the waiting fibril. */
-	fid_t fid;
-	
-	/** If true, this fibril is currently active. */
-	bool active;
-
-	/** Timeout wait data. */
-	to_event_t to_event;
-	/** Wakeup wait data. */
-	wu_event_t wu_event;
-} awaiter_t;
-
-extern void async_insert_timeout(awaiter_t *wd);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/async_sess.h
===================================================================
--- uspace/lib/c/include/async_sess.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/async_sess.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,5 +45,4 @@
 } async_sess_t;
 
-extern void _async_sess_init(void);
 extern void async_session_create(async_sess_t *, int, sysarg_t);
 extern void async_session_destroy(async_sess_t *);
Index: uspace/lib/c/include/byteorder.h
===================================================================
--- uspace/lib/c/include/byteorder.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/byteorder.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -80,8 +80,8 @@
 #endif
 
-#define htons(n)	host2uint16_t_be((n))
-#define htonl(n)	host2uint32_t_be((n))
-#define ntohs(n)	uint16_t_be2host((n))
-#define ntohl(n)	uint32_t_be2host((n))
+#define htons(n)  host2uint16_t_be((n))
+#define htonl(n)  host2uint32_t_be((n))
+#define ntohs(n)  uint16_t_be2host((n))
+#define ntohl(n)  uint32_t_be2host((n))
 
 static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ddi.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,4 +36,6 @@
 #define LIBC_DDI_H_
 
+#include <sys/types.h>
+#include <kernel/ddi/irq.h>
 #include <task.h>
 
@@ -42,4 +44,6 @@
 extern int iospace_enable(task_id_t, void *, unsigned long);
 extern int pio_enable(void *, size_t, void **);
+extern int register_irq(int, int, int, irq_code_t *);
+extern int unregister_irq(int, int);
 
 #endif
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/devman.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <bool.h>
 
-
 extern int devman_get_phone(devman_interface_t, unsigned int);
 extern void devman_hangup_phone(devman_interface_t);
Index: uspace/lib/c/include/err.h
===================================================================
--- uspace/lib/c/include/err.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/err.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,8 +39,8 @@
 
 #define errx(status, fmt, ...) \
-	{ \
+	do { \
 		printf((fmt), ##__VA_ARGS__); \
-		_exit(status); \
-	}
+		exit(status); \
+	} while (0)
 
 #endif
Index: uspace/lib/c/include/errno.h
===================================================================
--- uspace/lib/c/include/errno.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/errno.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,7 +39,7 @@
 #include <fibril.h>
 
+#define errno _errno
+
 extern int _errno;
-
-#define errno _errno
 
 #define EMFILE        (-18)
@@ -57,36 +57,35 @@
 
 /** An API function is called while another blocking function is in progress. */
-#define EINPROGRESS	(-10036)
+#define EINPROGRESS  (-10036)
 
 /** The socket identifier is not valid. */
-#define ENOTSOCK	(-10038)
+#define ENOTSOCK  (-10038)
 
 /** The destination address required. */
-#define EDESTADDRREQ	(-10039)
+#define EDESTADDRREQ  (-10039)
 
 /** Protocol is not supported.  */
-#define EPROTONOSUPPORT	(-10043)
+#define EPROTONOSUPPORT  (-10043)
 
 /** Socket type is not supported. */
-#define ESOCKTNOSUPPORT	(-10044)
+#define ESOCKTNOSUPPORT  (-10044)
 
 /** Protocol family is not supported. */
-#define EPFNOSUPPORT	(-10046)
+#define EPFNOSUPPORT  (-10046)
 
 /** Address family is not supported. */
-#define EAFNOSUPPORT	(-10047)
+#define EAFNOSUPPORT  (-10047)
 
 /** Address is already in use. */
-#define EADDRINUSE	(-10048)
+#define EADDRINUSE  (-10048)
 
 /** The socket is not connected or bound. */
-#define ENOTCONN	(-10057)
+#define ENOTCONN  (-10057)
 
 /** The requested operation was not performed. Try again later. */
-#define EAGAIN		(-11002)
+#define EAGAIN  (-11002)
 
-/** No data.
- */
-#define NO_DATA		(-11004)
+/** No data. */
+#define NO_DATA (-11004)
 
 #endif
Index: uspace/lib/c/include/event.h
===================================================================
--- uspace/lib/c/include/event.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/event.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 
 #include <kernel/ipc/event_types.h>
-#include <ipc/ipc.h>
 
 extern int event_subscribe(event_type_t, sysarg_t);
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/io/console.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define LIBC_IO_CONSOLE_H_
 
-#include <ipc/ipc.h>
 #include <bool.h>
 
Index: uspace/lib/c/include/io/screenbuffer.h
===================================================================
--- uspace/lib/c/include/io/screenbuffer.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/io/screenbuffer.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #include <stdint.h>
 #include <sys/types.h>
-#include <ipc/ipc.h>
 #include <bool.h>
 
Index: uspace/lib/c/include/ipc/adb.h
===================================================================
--- uspace/lib/c/include/ipc/adb.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/adb.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -32,15 +32,14 @@
 /** @file
  * @brief ADB device interface.
- */ 
+ */
 
 #ifndef LIBC_IPC_ADB_H_
 #define LIBC_IPC_ADB_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
 	ADB_REG_WRITE = IPC_FIRST_USER_METHOD
 } adb_request_t;
-
 
 typedef enum {
Index: uspace/lib/c/include/ipc/arp.h
===================================================================
--- uspace/lib/c/include/ipc/arp.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/arp.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #define LIBC_ARP_MESSAGES_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/bd.h
===================================================================
--- uspace/lib/c/include/ipc/bd.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/bd.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,10 +31,10 @@
  */
 /** @file
- */ 
+ */
 
 #ifndef LIBC_IPC_BD_H_
 #define LIBC_IPC_BD_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
Index: uspace/lib/c/include/ipc/char.h
===================================================================
--- uspace/lib/c/include/ipc/char.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/char.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -32,15 +32,14 @@
 /** @file
  * @brief Character device interface.
- */ 
+ */
 
 #ifndef LIBC_IPC_CHAR_H_
 #define LIBC_IPC_CHAR_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
 	CHAR_WRITE_BYTE = IPC_FIRST_USER_METHOD
 } char_request_t;
-
 
 typedef enum {
Index: uspace/lib/c/include/ipc/clipboard.h
===================================================================
--- uspace/lib/c/include/ipc/clipboard.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/clipboard.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,6 +36,4 @@
 #define LIBC_IPC_CLIPBOARD_H_
 
-#include <ipc/ipc.h>
-
 typedef enum {
 	CLIPBOARD_PUT_DATA = IPC_FIRST_USER_METHOD,
Index: uspace/lib/c/include/ipc/common.h
===================================================================
--- uspace/lib/c/include/ipc/common.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
+++ uspace/lib/c/include/ipc/common.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IPC_COMMON_H_
+#define LIBC_IPC_COMMON_H_
+
+#include <sys/types.h>
+#include <atomic.h>
+#include <kernel/ipc/ipc.h>
+
+#define IPC_FLAG_BLOCKING  0x01
+
+typedef struct {
+	sysarg_t args[IPC_CALL_LEN];
+	sysarg_t in_task_hash;
+	sysarg_t in_phone_hash;
+} ipc_call_t;
+
+typedef sysarg_t ipc_callid_t;
+
+extern atomic_t async_futex;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/console.h
===================================================================
--- uspace/lib/c/include/ipc/console.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/console.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define LIBC_IPC_CONSOLE_H_
 
-#include <ipc/ipc.h>
 #include <ipc/vfs.h>
 
Index: uspace/lib/c/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/c/include/ipc/dev_iface.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/dev_iface.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -30,5 +30,4 @@
 #define LIBC_IPC_DEV_IFACE_H_
 
-#include <ipc/ipc.h>
 #include <malloc.h>
 #include <unistd.h>
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/devman.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -30,15 +30,14 @@
  * @{
  */
- 
+
 #ifndef LIBC_IPC_DEVMAN_H_
 #define LIBC_IPC_DEVMAN_H_
 
+#include <ipc/common.h>
 #include <adt/list.h>
-#include <ipc/ipc.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <str.h>
+#include <malloc.h>
+#include <mem.h>
 
-#define DEVMAN_NAME_MAXLEN 256
+#define DEVMAN_NAME_MAXLEN  256
 
 typedef sysarg_t devman_handle_t;
@@ -67,6 +66,5 @@
 } match_id_list_t;
 
-
-static inline match_id_t * create_match_id()
+static inline match_id_t *create_match_id(void)
 {
 	match_id_t *id = malloc(sizeof(match_id_t));
@@ -85,8 +83,8 @@
 }
 
-static inline void add_match_id(match_id_list_t *ids, match_id_t *id) 
+static inline void add_match_id(match_id_list_t *ids, match_id_t *id)
 {
 	match_id_t *mid = NULL;
-	link_t *link = ids->ids.next;	
+	link_t *link = ids->ids.next;
 	
 	while (link != &ids->ids) {
@@ -98,5 +96,5 @@
 	}
 	
-	list_insert_before(&id->link, link);	
+	list_insert_before(&id->link, link);
 }
 
Index: uspace/lib/c/include/ipc/devmap.h
===================================================================
--- uspace/lib/c/include/ipc/devmap.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/devmap.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,7 +34,5 @@
 #define DEVMAP_DEVMAP_H_
 
-#include <atomic.h>
-#include <ipc/ipc.h>
-#include <adt/list.h>
+#include <ipc/common.h>
 
 #define DEVMAP_NAME_MAXLEN  255
Index: uspace/lib/c/include/ipc/fb.h
===================================================================
--- uspace/lib/c/include/ipc/fb.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/fb.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,10 +31,10 @@
  */
 /** @file
- */ 
+ */
 
 #ifndef LIBC_FB_H_
 #define LIBC_FB_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
Index: uspace/lib/c/include/ipc/icmp.h
===================================================================
--- uspace/lib/c/include/ipc/icmp.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/icmp.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,9 +39,7 @@
 #define LIBC_ICMP_MESSAGES_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 #include <sys/types.h>
 #include <sys/time.h>
-
 #include <net/icmp_codes.h>
 
Index: uspace/lib/c/include/ipc/il.h
===================================================================
--- uspace/lib/c/include/ipc/il.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/il.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #define LIBC_IL_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/ip.h
===================================================================
--- uspace/lib/c/include/ipc/ip.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/ip.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,7 +39,5 @@
 #define LIBC_IP_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
-
 #include <net/in.h>
 #include <net/ip_codes.h>
Index: uspace/lib/c/include/ipc/ipc.h
===================================================================
--- uspace/lib/c/include/ipc/ipc.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/ipc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,24 +33,17 @@
  */
 
-#ifndef LIBIPC_IPC_H_
-#define LIBIPC_IPC_H_
-
+#if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
+	#error Do not intermix low-level IPC interface and async framework
+#endif
+
+#ifndef LIBC_IPC_H_
+#define LIBC_IPC_H_
+
+#include <sys/types.h>
+#include <ipc/common.h>
+#include <kernel/synch/synch.h>
 #include <task.h>
-#include <kernel/ipc/ipc.h>
-#include <kernel/ddi/irq.h>
-#include <sys/types.h>
-#include <kernel/synch/synch.h>
-
-#define IPC_FLAG_BLOCKING  0x01
-
-typedef struct {
-	sysarg_t args[IPC_CALL_LEN];
-	sysarg_t in_task_hash;
-	sysarg_t in_phone_hash;
-} ipc_call_t;
-
-typedef sysarg_t ipc_callid_t;
-
-typedef void (* ipc_async_callback_t)(void *, int, ipc_call_t *);
+
+typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
 
 /*
@@ -60,4 +53,5 @@
  * possible, the fast version is used.
  */
+
 #define ipc_call_sync_0_0(phoneid, method) \
 	ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
@@ -189,13 +183,11 @@
     sysarg_t *);
 
-extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
-extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t);
+extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
 extern void ipc_poke(void);
 
-static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
-{
-	return ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
-}
-
+#define ipc_wait_for_call(data) \
+	ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
+
+extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
 extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
 
@@ -206,4 +198,5 @@
  * to m.
  */
+
 #define ipc_answer_0(callid, retval) \
 	ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
@@ -230,4 +223,5 @@
  * to m.
  */
+
 #define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
 	ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
@@ -255,21 +249,24 @@
 
 extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
-    sysarg_t, void *, ipc_async_callback_t, int);
+    sysarg_t, void *, ipc_async_callback_t, bool);
 extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
-    sysarg_t, sysarg_t, void *, ipc_async_callback_t, int);
-
-extern int ipc_connect_to_me(int, int, int, int, sysarg_t *, sysarg_t *);
-extern int ipc_connect_me_to(int, int, int, int);
-extern int ipc_connect_me_to_blocking(int, int, int, int);
+    sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
+
+extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t *,
+    sysarg_t *);
+extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
+extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
+
 extern int ipc_hangup(int);
-extern int ipc_register_irq(int, int, int, irq_code_t *);
-extern int ipc_unregister_irq(int, int);
-extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
-extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
-    sysarg_t, sysarg_t, sysarg_t, int);
+
+extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
+    unsigned int);
+extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, unsigned int);
 
 /*
  * User-friendly wrappers for ipc_share_in_start().
  */
+
 #define ipc_share_in_start_0_0(phoneid, dst, size) \
 	ipc_share_in_start((phoneid), (dst), (size), 0, NULL)
@@ -281,7 +278,7 @@
 	ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
 
-extern int ipc_share_in_start(int, void *, size_t, sysarg_t, int *);
-extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
-extern int ipc_share_out_start(int, void *, int);
+extern int ipc_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
+extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int);
+extern int ipc_share_out_start(int, void *, unsigned int);
 extern int ipc_share_out_finalize(ipc_callid_t, void *);
 extern int ipc_data_read_start(int, void *, size_t);
Index: uspace/lib/c/include/ipc/irc.h
===================================================================
--- uspace/lib/c/include/ipc/irc.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/irc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,5 @@
 #define LIBC_IRC_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
Index: uspace/lib/c/include/ipc/kbd.h
===================================================================
--- uspace/lib/c/include/ipc/kbd.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/kbd.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,5 @@
 #define LIBC_IPC_KBD_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 #include <ipc/dev_iface.h>
 
Index: uspace/lib/c/include/ipc/loader.h
===================================================================
--- uspace/lib/c/include/ipc/loader.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/loader.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -31,10 +31,10 @@
  */
 /** @file
- */ 
+ */
 
 #ifndef LIBC_IPC_LOADER_H_
 #define LIBC_IPC_LOADER_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
Index: uspace/lib/c/include/ipc/mouse.h
===================================================================
--- uspace/lib/c/include/ipc/mouse.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/mouse.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,5 @@
 #define LIBC_IPC_MOUSE_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 typedef enum {
Index: uspace/lib/c/include/ipc/net.h
===================================================================
--- uspace/lib/c/include/ipc/net.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/net.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,7 +38,5 @@
 #define LIBC_NET_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <net/device.h>
 #include <net/packet.h>
Index: uspace/lib/c/include/ipc/net_net.h
===================================================================
--- uspace/lib/c/include/ipc/net_net.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/net_net.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #define LIBC_NET_NET_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/netif.h
===================================================================
--- uspace/lib/c/include/ipc/netif.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/netif.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #define LIBC_NETIF_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/nil.h
===================================================================
--- uspace/lib/c/include/ipc/nil.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/nil.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #define LIBC_NIL_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/ns.h
===================================================================
--- uspace/lib/c/include/ipc/ns.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/ns.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,8 +33,9 @@
  */
 
-#ifndef LIBIPC_NS_H_
-#define LIBIPC_NS_H_
+#ifndef LIBC_NS_H_
+#define LIBC_NS_H_
 
-#include <ipc/ipc.h>
+#include <sys/types.h>
+#include <ipc/common.h>
 
 typedef enum {
@@ -45,4 +46,8 @@
 } ns_request_t;
 
+extern int service_register(sysarg_t);
+extern int service_connect(sysarg_t, sysarg_t, sysarg_t);
+extern int service_connect_blocking(sysarg_t, sysarg_t, sysarg_t);
+
 #endif
 
Index: uspace/lib/c/include/ipc/packet.h
===================================================================
--- uspace/lib/c/include/ipc/packet.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/packet.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #define LIBC_PACKET_MESSAGES_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/services.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,6 +35,6 @@
  */
 
-#ifndef LIBIPC_SERVICES_H_
-#define LIBIPC_SERVICES_H_
+#ifndef LIBC_SERVICES_H_
+#define LIBC_SERVICES_H_
 
 typedef enum {
@@ -66,8 +66,4 @@
 } services_t;
 
-/* Memory area to be received from NS */
-#define SERVICE_MEM_REALTIME    1
-#define SERVICE_MEM_KLOG        2
-
 #endif
 
Index: uspace/lib/c/include/ipc/socket.h
===================================================================
--- uspace/lib/c/include/ipc/socket.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/socket.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #define LIBC_SOCKET_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/tl.h
===================================================================
--- uspace/lib/c/include/ipc/tl.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/tl.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #define LIBC_TL_MESSAGES_H_
 
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 
Index: uspace/lib/c/include/ipc/vfs.h
===================================================================
--- uspace/lib/c/include/ipc/vfs.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/ipc/vfs.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,5 @@
 #define LIBC_IPC_VFS_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 #include <sys/types.h>
 #include <bool.h>
Index: uspace/lib/c/include/libc.h
===================================================================
--- uspace/lib/c/include/libc.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/libc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -62,7 +62,4 @@
 	__syscall6(p1, p2, p3, p4, p5, p6, id)
 
-extern void __main(void *pcb_ptr);
-extern void __exit(void);
-
 #endif
 
Index: uspace/lib/c/include/loader/pcb.h
===================================================================
--- uspace/lib/c/include/loader/pcb.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/loader/pcb.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -52,5 +52,5 @@
 	/** Program entry point. */
 	entry_point_t entry;
-
+	
 	/** Current working directory. */
 	char *cwd;
Index: uspace/lib/c/include/malloc.h
===================================================================
--- uspace/lib/c/include/malloc.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/malloc.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,7 +38,4 @@
 #include <sys/types.h>
 
-extern void __heap_init(void);
-extern uintptr_t get_max_heap_addr(void);
-
 extern void *malloc(const size_t size)
     __attribute__((malloc));
Index: uspace/lib/c/include/net/modules.h
===================================================================
--- uspace/lib/c/include/net/modules.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/net/modules.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,8 +43,5 @@
 
 #include <async.h>
-
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <sys/time.h>
 
Index: uspace/lib/c/include/setjmp.h
===================================================================
--- uspace/lib/c/include/setjmp.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/setjmp.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,5 @@
 
 extern int setjmp(jmp_buf env);
-extern void longjmp(jmp_buf env,int val) __attribute__((__noreturn__));
+extern void longjmp(jmp_buf env, int val) __attribute__((noreturn));
 
 #endif
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/stdlib.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,29 +40,13 @@
 #include <stacktrace.h>
 
-#define abort() \
-	do { \
-		stacktrace_print(); \
-		_exit(1); \
-	} while (0)
+#define RAND_MAX  714025
 
-#define core() \
-	*((int *) 0) = 0xbadbad;
-
-#define exit(status)  _exit((status))
-
-#define RAND_MAX  714025
+#define rand()       random()
+#define srand(seed)  srandom(seed)
 
 extern long int random(void);
 extern void srandom(unsigned int seed);
 
-static inline int rand(void)
-{
-	return random();
-}
-
-static inline void srand(unsigned int seed)
-{
-	srandom(seed);
-}
+extern void abort(void) __attribute__((noreturn));
 
 #endif
Index: uspace/lib/c/include/syscall.h
===================================================================
--- uspace/lib/c/include/syscall.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/syscall.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -32,7 +32,7 @@
 /**
  * @file
- * @brief	Syscall function declaration for architectures that don't
- *		inline syscalls or architectures that handle syscalls
- *		according to the number of arguments.
+ * @brief Syscall function declaration for architectures that don't
+ *        inline syscalls or architectures that handle syscalls
+ *        according to the number of arguments.
  */
 
@@ -40,6 +40,6 @@
 #define LIBC_SYSCALL_H_
 
-#ifndef	LIBARCH_SYSCALL_GENERIC
-#error "You can't include this file directly."
+#ifndef LIBARCH_SYSCALL_GENERIC
+	#error You cannot include this file directly
 #endif
 
@@ -47,11 +47,11 @@
 #include <kernel/syscall/syscall.h>
 
-#define __syscall0	__syscall
-#define __syscall1	__syscall
-#define __syscall2	__syscall
-#define __syscall3	__syscall
-#define __syscall4	__syscall
-#define __syscall5	__syscall
-#define __syscall6	__syscall
+#define __syscall0  __syscall
+#define __syscall1  __syscall
+#define __syscall2  __syscall
+#define __syscall3  __syscall
+#define __syscall4  __syscall
+#define __syscall5  __syscall
+#define __syscall6  __syscall
 
 extern sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2,
Index: uspace/lib/c/include/thread.h
===================================================================
--- uspace/lib/c/include/thread.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/thread.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define LIBC_THREAD_H_
 
-#include <kernel/proc/uarg.h>
 #include <libarch/thread.h>
 #include <sys/types.h>
@@ -42,9 +41,6 @@
 typedef uint64_t thread_id_t;
 
-extern void __thread_entry(void);
-extern void __thread_main(uspace_arg_t *);
-
 extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
-extern void thread_exit(int) __attribute__ ((noreturn));
+extern void thread_exit(int) __attribute__((noreturn));
 extern void thread_detach(thread_id_t);
 extern int thread_join(thread_id_t);
Index: uspace/lib/c/include/tls.h
===================================================================
--- uspace/lib/c/include/tls.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/tls.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -57,4 +57,5 @@
 extern void tls_free_variant_1(tcb_t *, size_t);
 #endif
+
 #ifdef CONFIG_TLS_VARIANT_2
 extern tcb_t *tls_alloc_variant_2(void **, size_t);
Index: uspace/lib/c/include/udebug.h
===================================================================
--- uspace/lib/c/include/udebug.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/udebug.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,23 +38,18 @@
 #include <kernel/udebug/udebug.h>
 #include <sys/types.h>
-#include <libarch/types.h>
 
 typedef sysarg_t thash_t;
 
-int udebug_begin(int phoneid);
-int udebug_end(int phoneid);
-int udebug_set_evmask(int phoneid, udebug_evmask_t mask);
-int udebug_thread_read(int phoneid, void *buffer, size_t n,
-	size_t *copied, size_t *needed);
-int udebug_name_read(int phoneid, void *buffer, size_t n,
-	size_t *copied, size_t *needed);
-int udebug_areas_read(int phoneid, void *buffer, size_t n,
-	size_t *copied, size_t *needed);
-int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
-int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
-int udebug_regs_read(int phoneid, thash_t tid, void *buffer);
-int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type,
-	sysarg_t *val0, sysarg_t *val1);
-int udebug_stop(int phoneid, thash_t tid);
+int udebug_begin(int);
+int udebug_end(int);
+int udebug_set_evmask(int, udebug_evmask_t);
+int udebug_thread_read(int, void *, size_t , size_t *, size_t *);
+int udebug_name_read(int, void *, size_t, size_t *, size_t *);
+int udebug_areas_read(int, void *, size_t, size_t *, size_t *);
+int udebug_mem_read(int, void *, uintptr_t, size_t);
+int udebug_args_read(int, thash_t, sysarg_t *);
+int udebug_regs_read(int, thash_t, void *);
+int udebug_go(int, thash_t, udebug_event_t *, sysarg_t *, sysarg_t *);
+int udebug_stop(int, thash_t);
 
 #endif
Index: uspace/lib/c/include/unistd.h
===================================================================
--- uspace/lib/c/include/unistd.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/unistd.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,8 +41,6 @@
 
 #ifndef NULL
-	#define NULL	((void *) 0)
+	#define NULL  ((void *) 0)
 #endif
-
-#define getpagesize()  (PAGE_SIZE)
 
 #ifndef SEEK_SET
@@ -57,4 +55,6 @@
 	#define SEEK_END  2
 #endif
+
+#define getpagesize()  (PAGE_SIZE)
 
 extern int dup2(int oldfd, int newfd);
@@ -74,5 +74,5 @@
 extern int chdir(const char *);
 
-extern void _exit(int) __attribute__((noreturn));
+extern void exit(int) __attribute__((noreturn));
 extern int usleep(useconds_t);
 extern unsigned int sleep(unsigned int);
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/c/include/vfs/vfs.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -57,7 +57,4 @@
 extern int unmount(const char *);
 
-extern void __stdio_init(int filc, fdi_node_t *filv[]);
-extern void __stdio_done(void);
-
 extern int open_node(fdi_node_t *, int);
 extern int fd_phone(int);
Index: uspace/lib/clui/tinput.h
===================================================================
--- uspace/lib/clui/tinput.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/clui/tinput.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,6 +36,4 @@
 #ifndef LIBCLUI_TINPUT_H_
 #define LIBCLUI_TINPUT_H_
-
-#include <ipc/ipc.h>
 
 #define HISTORY_LEN     10
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/generic/driver.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -186,5 +186,5 @@
 		pseudocode = &default_pseudocode;
 	
-	int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode);
+	int res = register_irq(irq, dev->handle, ctx->id, pseudocode);
 	if (res != EOK) {
 		remove_interrupt_context(&interrupt_contexts, ctx);
@@ -199,5 +199,5 @@
 	interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
 	    dev, irq);
-	int res = ipc_unregister_irq(irq, dev->handle);
+	int res = unregister_irq(irq, dev->handle);
 	
 	if (ctx != NULL) {
@@ -272,5 +272,5 @@
 	}
 	
-	ipc_answer_0(iid, res);
+	async_answer_0(iid, res);
 }
 
@@ -278,5 +278,5 @@
 {
 	/* Accept connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	bool cont = true;
@@ -293,5 +293,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOENT);
+			async_answer_0(callid, ENOENT);
 		}
 	}
@@ -316,5 +316,5 @@
 		printf("%s: driver_connection_gen error - no device with handle"
 		    " %" PRIun " was found.\n", driver->name, handle);
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -331,5 +331,5 @@
 		ret = (*dev->ops->open)(dev);
 	
-	ipc_answer_0(iid, ret);
+	async_answer_0(iid, ret);
 	if (ret != EOK)
 		return;
@@ -347,5 +347,5 @@
 			if (dev->ops != NULL && dev->ops->close != NULL)
 				(*dev->ops->close)(dev);
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		default:
@@ -368,5 +368,5 @@
 				    "invalid interface id %d.",
 				    driver->name, iface_idx);
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				break;
 			}
@@ -381,5 +381,5 @@
 				printf("device with handle %" PRIun " has no interface "
 				    "with id %d.\n", handle, iface_idx);
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				break;
 			}
@@ -400,5 +400,5 @@
 				printf("%s: driver_connection_gen error - "
 				    "invalid interface method.", driver->name);
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				break;
 			}
@@ -446,5 +446,5 @@
 	default:
 		/* No such interface */
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 	}
 }
Index: uspace/lib/drv/generic/remote_char_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_char_dev.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/generic/remote_char_dev.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,5 +33,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <errno.h>
@@ -81,5 +80,5 @@
 	if (!async_data_read_receive(&cid, &len)) {
 		/* TODO handle protocol error. */
-		ipc_answer_0(callid, EINVAL);
+		async_answer_0(callid, EINVAL);
 		return;
 	}
@@ -87,5 +86,5 @@
 	if (!char_dev_ops->read) {
 		async_data_read_finalize(cid, NULL, 0);
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -100,5 +99,5 @@
 		/* Some error occured. */
 		async_data_read_finalize(cid, buf, 0);
-		ipc_answer_0(callid, ret);
+		async_answer_0(callid, ret);
 		return;
 	}
@@ -106,5 +105,5 @@
 	/* The operation was successful, return the number of data read. */
 	async_data_read_finalize(cid, buf, ret);
-	ipc_answer_1(callid, EOK, ret);
+	async_answer_1(callid, EOK, ret);
 }
 
@@ -128,5 +127,5 @@
 	if (!async_data_write_receive(&cid, &len)) {
 		/* TODO handle protocol error. */
-		ipc_answer_0(callid, EINVAL);
+		async_answer_0(callid, EINVAL);
 		return;
 	}
@@ -134,5 +133,5 @@
 	if (!char_dev_ops->write) {
 		async_data_write_finalize(cid, NULL, 0);
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -148,5 +147,5 @@
 	if (ret < 0) {
 		/* Some error occured. */
-		ipc_answer_0(callid, ret);
+		async_answer_0(callid, ret);
 	} else {
 		/*
@@ -154,5 +153,5 @@
 		 * written.
 		 */
-		ipc_answer_1(callid, EOK, ret);
+		async_answer_1(callid, EOK, ret);
 	}
 }
Index: uspace/lib/drv/generic/remote_hw_res.c
===================================================================
--- uspace/lib/drv/generic/remote_hw_res.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/generic/remote_hw_res.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,5 +33,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <errno.h>
@@ -62,9 +61,9 @@
 	
 	if (hw_res_ops->enable_interrupt == NULL)
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 	else if (hw_res_ops->enable_interrupt(dev))
-		ipc_answer_0(callid, EOK);
+		async_answer_0(callid, EOK);
 	else
-		ipc_answer_0(callid, EREFUSED);
+		async_answer_0(callid, EREFUSED);
 }
 
@@ -75,5 +74,5 @@
 
 	if (hw_res_ops->get_resource_list == NULL) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -81,9 +80,9 @@
 	hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev);
 	if (hw_resources == NULL){
-		ipc_answer_0(callid, ENOENT);
+		async_answer_0(callid, ENOENT);
 		return;
 	}
 	
-	ipc_answer_1(callid, EOK, hw_resources->count);
+	async_answer_1(callid, EOK, hw_resources->count);
 
 	size_t len;
Index: uspace/lib/drv/generic/remote_usb.c
===================================================================
--- uspace/lib/drv/generic/remote_usb.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/generic/remote_usb.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,5 +33,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <errno.h>
@@ -64,5 +63,5 @@
 
 	if (usb_iface->get_hc_handle == NULL) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -71,8 +70,8 @@
 	int rc = usb_iface->get_hc_handle(device, &handle);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 	}
 
-	ipc_answer_1(callid, EOK, (sysarg_t) handle);
+	async_answer_1(callid, EOK, (sysarg_t) handle);
 }
 
Index: uspace/lib/drv/generic/remote_usbhc.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/generic/remote_usbhc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,5 +33,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <errno.h>
@@ -141,5 +140,5 @@
 
 	if (!usb_iface->tell_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -150,7 +149,7 @@
 	int rc = usb_iface->tell_address(device, handle, &address);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 	} else {
-		ipc_answer_1(callid, EOK, address);
+		async_answer_1(callid, EOK, address);
 	}
 }
@@ -162,9 +161,9 @@
 	async_transaction_t * trans = (async_transaction_t *)buffer_hash;
 	if (trans == NULL) {
-		ipc_answer_0(callid, ENOENT);
+		async_answer_0(callid, ENOENT);
 		return;
 	}
 	if (trans->buffer == NULL) {
-		ipc_answer_0(callid, EINVAL);
+		async_answer_0(callid, EINVAL);
 		async_transaction_destroy(trans);
 		return;
@@ -174,5 +173,5 @@
 	size_t accepted_size;
 	if (!async_data_read_receive(&cid, &accepted_size)) {
-		ipc_answer_0(callid, EINVAL);
+		async_answer_0(callid, EINVAL);
 		async_transaction_destroy(trans);
 		return;
@@ -184,5 +183,5 @@
 	async_data_read_finalize(cid, trans->buffer, accepted_size);
 
-	ipc_answer_1(callid, EOK, accepted_size);
+	async_answer_1(callid, EOK, accepted_size);
 
 	async_transaction_destroy(trans);
@@ -195,5 +194,5 @@
 
 	if (!usb_iface->reserve_default_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -201,5 +200,5 @@
 	int rc = usb_iface->reserve_default_address(device);
 
-	ipc_answer_0(callid, rc);
+	async_answer_0(callid, rc);
 }
 
@@ -210,5 +209,5 @@
 
 	if (!usb_iface->release_default_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -216,5 +215,5 @@
 	int rc = usb_iface->release_default_address(device);
 
-	ipc_answer_0(callid, rc);
+	async_answer_0(callid, rc);
 }
 
@@ -225,5 +224,5 @@
 
 	if (!usb_iface->request_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -232,7 +231,7 @@
 	int rc = usb_iface->request_address(device, &address);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 	} else {
-		ipc_answer_1(callid, EOK, (sysarg_t) address);
+		async_answer_1(callid, EOK, (sysarg_t) address);
 	}
 }
@@ -244,5 +243,5 @@
 
 	if (!usb_iface->bind_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -253,5 +252,5 @@
 	int rc = usb_iface->bind_address(device, address, handle);
 
-	ipc_answer_0(callid, rc);
+	async_answer_0(callid, rc);
 }
 
@@ -262,5 +261,5 @@
 
 	if (!usb_iface->release_address) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -270,5 +269,5 @@
 	int rc = usb_iface->release_address(device, address);
 
-	ipc_answer_0(callid, rc);
+	async_answer_0(callid, rc);
 }
 
@@ -279,5 +278,5 @@
 	async_transaction_t *trans = (async_transaction_t *)arg;
 
-	ipc_answer_0(trans->caller, outcome);
+	async_answer_0(trans->caller, outcome);
 
 	async_transaction_destroy(trans);
@@ -290,5 +289,5 @@
 
 	if (outcome != USB_OUTCOME_OK) {
-		ipc_answer_0(trans->caller, outcome);
+		async_answer_0(trans->caller, outcome);
 		async_transaction_destroy(trans);
 		return;
@@ -296,5 +295,5 @@
 
 	trans->size = actual_size;
-	ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans);
+	async_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans);
 }
 
@@ -311,5 +310,5 @@
 {
 	if (!transfer_func) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -329,5 +328,5 @@
 
 		if (rc != EOK) {
-			ipc_answer_0(callid, rc);
+			async_answer_0(callid, rc);
 			return;
 		}
@@ -339,5 +338,5 @@
 			free(buffer);
 		}
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return;
 	}
@@ -350,5 +349,5 @@
 
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		async_transaction_destroy(trans);
 	}
@@ -367,5 +366,5 @@
 {
 	if (!transfer_func) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -379,5 +378,5 @@
 	async_transaction_t *trans = async_transaction_create(callid);
 	if (trans == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return;
 	}
@@ -389,5 +388,5 @@
 
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		async_transaction_destroy(trans);
 	}
@@ -414,5 +413,5 @@
 		case USB_DIRECTION_IN:
 			if (!transfer_in_func) {
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				return;
 			}
@@ -420,5 +419,5 @@
 		case USB_DIRECTION_OUT:
 			if (!transfer_out_func) {
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				return;
 			}
@@ -436,5 +435,5 @@
 	async_transaction_t *trans = async_transaction_create(callid);
 	if (trans == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return;
 	}
@@ -456,5 +455,5 @@
 
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		async_transaction_destroy(trans);
 	}
@@ -549,5 +548,5 @@
 
 	if (!usb_iface->control_write) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -568,5 +567,5 @@
 	    1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		return;
 	}
@@ -574,5 +573,5 @@
 	    1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		free(setup_packet);
 		return;
@@ -581,5 +580,5 @@
 	async_transaction_t *trans = async_transaction_create(callid);
 	if (trans == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		free(setup_packet);
 		free(data_buffer);
@@ -596,5 +595,5 @@
 
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		async_transaction_destroy(trans);
 	}
@@ -609,5 +608,5 @@
 
 	if (!usb_iface->control_read) {
-		ipc_answer_0(callid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
 		return;
 	}
@@ -627,5 +626,5 @@
 	    1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		return;
 	}
@@ -633,5 +632,5 @@
 	async_transaction_t *trans = async_transaction_create(callid);
 	if (trans == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		free(setup_packet);
 		return;
@@ -641,5 +640,5 @@
 	trans->buffer = malloc(data_len);
 	if (trans->buffer == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		async_transaction_destroy(trans);
 		return;
@@ -652,5 +651,5 @@
 
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		async_transaction_destroy(trans);
 	}
Index: uspace/lib/drv/include/dev_iface.h
===================================================================
--- uspace/lib/drv/include/dev_iface.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/include/dev_iface.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,4 +36,5 @@
 #define LIBDRV_DEV_IFACE_H_
 
+#include <ipc/common.h>
 #include <ipc/dev_iface.h>
 
Index: uspace/lib/drv/include/driver.h
===================================================================
--- uspace/lib/drv/include/driver.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/drv/include/driver.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,6 +36,7 @@
 #define LIBDRV_DRIVER_H_
 
+#include <sys/types.h>
+#include <kernel/ddi/irq.h>
 #include <adt/list.h>
-#include <ipc/ipc.h>
 #include <devman.h>
 #include <ipc/devman.h>
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/fs/libfs.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <errno.h>
 #include <async.h>
-#include <ipc/ipc.h>
 #include <as.h>
 #include <assert.h>
@@ -58,5 +57,5 @@
 #define answer_and_return(rid, rc) \
 	do { \
-		ipc_answer_0((rid), (rc)); \
+		async_answer_0((rid), (rc)); \
 		return; \
 	} while (0)
@@ -102,6 +101,5 @@
 	 * Ask VFS for callback connection.
 	 */
-	sysarg_t taskhash;
-	ipc_connect_to_me(vfs_phone, 0, 0, 0, &taskhash, &reg->vfs_phonehash);
+	async_connect_to_me(vfs_phone, 0, 0, 0, conn);
 	
 	/*
@@ -128,9 +126,4 @@
 	async_wait_for(req, NULL);
 	reg->fs_handle = (int) IPC_GET_ARG1(answer);
-	
-	/*
-	 * Create a connection fibril to handle the callback connection.
-	 */
-	async_new_connection(taskhash, reg->vfs_phonehash, 0, NULL, conn);
 	
 	/*
@@ -166,26 +159,26 @@
 	if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||
 	    (mountee_phone < 0)) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
 	
 	/* Acknowledge the mountee_phone */
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 	
 	fs_node_t *fn;
 	res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
 	if ((res != EOK) || (!fn)) {
-		ipc_hangup(mountee_phone);
+		async_hangup(mountee_phone);
 		async_data_write_void(combine_rc(res, ENOENT));
-		ipc_answer_0(rid, combine_rc(res, ENOENT));
+		async_answer_0(rid, combine_rc(res, ENOENT));
 		return;
 	}
 	
 	if (fn->mp_data.mp_active) {
-		ipc_hangup(mountee_phone);
+		async_hangup(mountee_phone);
 		(void) ops->node_put(fn);
 		async_data_write_void(EBUSY);
-		ipc_answer_0(rid, EBUSY);
+		async_answer_0(rid, EBUSY);
 		return;
 	}
@@ -193,8 +186,8 @@
 	rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME);
 	if (rc != EOK) {
-		ipc_hangup(mountee_phone);
+		async_hangup(mountee_phone);
 		(void) ops->node_put(fn);
 		async_data_write_void(rc);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -214,5 +207,5 @@
 	 * Do not release the FS node so that it stays in memory.
 	 */
-	ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
+	async_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
 	    IPC_GET_ARG3(answer));
 }
@@ -227,5 +220,5 @@
 	res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
 	if ((res != EOK) || (!fn)) {
-		ipc_answer_0(rid, combine_rc(res, ENOENT));
+		async_answer_0(rid, combine_rc(res, ENOENT));
 		return;
 	}
@@ -236,5 +229,5 @@
 	if (!fn->mp_data.mp_active) {
 		(void) ops->node_put(fn);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -250,5 +243,5 @@
 	 */
 	if (res == EOK) {
-		ipc_hangup(fn->mp_data.phone);
+		async_hangup(fn->mp_data.phone);
 		fn->mp_data.mp_active = false;
 		fn->mp_data.fs_handle = 0;
@@ -260,5 +253,5 @@
 
 	(void) ops->node_put(fn);
-	ipc_answer_0(rid, res);
+	async_answer_0(rid, res);
 }
 
@@ -300,5 +293,5 @@
 	
 	if (cur->mp_data.mp_active) {
-		ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
+		async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
 		    next, last, cur->mp_data.devmap_handle, lflag, index,
 		    IPC_FF_ROUTE_FROM_ME);
@@ -324,5 +317,5 @@
 			if (len + 1 == NAME_MAX) {
 				/* Component length overflow */
-				ipc_answer_0(rid, ENAMETOOLONG);
+				async_answer_0(rid, ENAMETOOLONG);
 				goto out;
 			}
@@ -358,5 +351,5 @@
 				next--;
 			
-			ipc_forward_slow(rid, tmp->mp_data.phone,
+			async_forward_slow(rid, tmp->mp_data.phone,
 			    VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle,
 			    lflag, index, IPC_FF_ROUTE_FROM_ME);
@@ -372,5 +365,5 @@
 			if (next <= last) {
 				/* There are unprocessed components */
-				ipc_answer_0(rid, ENOENT);
+				async_answer_0(rid, ENOENT);
 				goto out;
 			}
@@ -380,5 +373,5 @@
 				/* Request to create a new link */
 				if (!ops->is_directory(cur)) {
-					ipc_answer_0(rid, ENOTDIR);
+					async_answer_0(rid, ENOTDIR);
 					goto out;
 				}
@@ -398,8 +391,8 @@
 						if (lflag & L_CREATE)
 							(void) ops->destroy(fn);
-						ipc_answer_0(rid, rc);
+						async_answer_0(rid, rc);
 					} else {
 						aoff64_t size = ops->size_get(fn);
-						ipc_answer_5(rid, fs_handle,
+						async_answer_5(rid, fs_handle,
 						    devmap_handle,
 						    ops->index_get(fn),
@@ -410,10 +403,10 @@
 					}
 				} else
-					ipc_answer_0(rid, ENOSPC);
+					async_answer_0(rid, ENOSPC);
 				
 				goto out;
 			}
 			
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			goto out;
 		}
@@ -441,5 +434,5 @@
 		if (lflag & (L_CREATE | L_LINK)) {
 			if (!ops->is_directory(cur)) {
-				ipc_answer_0(rid, ENOTDIR);
+				async_answer_0(rid, ENOTDIR);
 				goto out;
 			}
@@ -450,5 +443,5 @@
 				if (ops->plb_get_char(next) == '/') {
 					/* More than one component */
-					ipc_answer_0(rid, ENOENT);
+					async_answer_0(rid, ENOENT);
 					goto out;
 				}
@@ -456,5 +449,5 @@
 				if (len + 1 == NAME_MAX) {
 					/* Component length overflow */
-					ipc_answer_0(rid, ENAMETOOLONG);
+					async_answer_0(rid, ENAMETOOLONG);
 					goto out;
 				}
@@ -480,8 +473,8 @@
 					if (lflag & L_CREATE)
 						(void) ops->destroy(fn);
-					ipc_answer_0(rid, rc);
+					async_answer_0(rid, rc);
 				} else {
 					aoff64_t size = ops->size_get(fn);
-					ipc_answer_5(rid, fs_handle,
+					async_answer_5(rid, fs_handle,
 					    devmap_handle,
 					    ops->index_get(fn),
@@ -492,10 +485,10 @@
 				}
 			} else
-				ipc_answer_0(rid, ENOSPC);
+				async_answer_0(rid, ENOSPC);
 			
 			goto out;
 		}
 		
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		goto out;
 	}
@@ -510,9 +503,9 @@
 		if (rc == EOK) {
 			aoff64_t size = ops->size_get(cur);
-			ipc_answer_5(rid, fs_handle, devmap_handle,
+			async_answer_5(rid, fs_handle, devmap_handle,
 			    ops->index_get(cur), LOWER32(size), UPPER32(size),
 			    old_lnkcnt);
 		} else
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 		
 		goto out;
@@ -521,20 +514,20 @@
 	if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) ||
 	    (lflag & L_LINK)) {
-		ipc_answer_0(rid, EEXIST);
+		async_answer_0(rid, EEXIST);
 		goto out;
 	}
 	
 	if ((lflag & L_FILE) && (ops->is_directory(cur))) {
-		ipc_answer_0(rid, EISDIR);
+		async_answer_0(rid, EISDIR);
 		goto out;
 	}
 	
 	if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) {
-		ipc_answer_0(rid, ENOTDIR);
+		async_answer_0(rid, ENOTDIR);
 		goto out;
 	}
 
 	if ((lflag & L_ROOT) && par) {
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		goto out;
 	}
@@ -548,12 +541,12 @@
 		if (rc == EOK) {
 			aoff64_t size = ops->size_get(cur);
-			ipc_answer_5(rid, fs_handle, devmap_handle,
+			async_answer_5(rid, fs_handle, devmap_handle,
 			    ops->index_get(cur), LOWER32(size), UPPER32(size),
 			    ops->lnkcnt_get(cur));
 		} else
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 		
 	} else
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 	
 out:
@@ -584,6 +577,6 @@
 	    (size != sizeof(struct stat))) {
 		ops->node_put(fn);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -604,5 +597,5 @@
 	
 	async_data_read_finalize(callid, &stat, sizeof(struct stat));
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -626,5 +619,5 @@
 	
 	if (fn == NULL) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -632,5 +625,5 @@
 	rc = ops->node_open(fn);
 	aoff64_t size = ops->size_get(fn);
-	ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
+	async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
 	    (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
 	
Index: uspace/lib/fs/libfs.h
===================================================================
--- uspace/lib/fs/libfs.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/fs/libfs.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #include <ipc/vfs.h>
 #include <stdint.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <devmap.h>
@@ -86,5 +85,4 @@
 typedef struct {
 	int fs_handle;           /**< File system handle. */
-	sysarg_t vfs_phonehash;  /**< Initial VFS phonehash. */
 	uint8_t *plb_ro;         /**< Read-only PLB view. */
 } fs_reg_t;
Index: uspace/lib/net/generic/generic.c
===================================================================
--- uspace/lib/net/generic/generic.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/generic/generic.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,9 +36,6 @@
 
 #include <generic.h>
-
 #include <async.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <net/device.h>
 #include <adt/measured_strings.h>
Index: uspace/lib/net/generic/packet_remote.c
===================================================================
--- uspace/lib/net/generic/packet_remote.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/generic/packet_remote.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #include <async.h>
 #include <errno.h>
-#include <ipc/ipc.h>
 #include <ipc/packet.h>
 #include <sys/mman.h>
Index: uspace/lib/net/il/arp_remote.c
===================================================================
--- uspace/lib/net/il/arp_remote.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/il/arp_remote.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <errno.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/arp.h>
Index: uspace/lib/net/il/il_skel.c
===================================================================
--- uspace/lib/net/il/il_skel.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/il/il_skel.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -54,5 +54,5 @@
 	 * the initial IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -115,5 +115,5 @@
 		goto out;
 	
-	rc = ipc_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
+	rc = async_connect_to_me(PHONE_NS, service, 0, 0, NULL);
 	if (rc != EOK)
 		goto out;
Index: uspace/lib/net/include/generic.h
===================================================================
--- uspace/lib/net/include/generic.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/include/generic.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 
 #include <async.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 
Index: uspace/lib/net/include/il_skel.h
===================================================================
--- uspace/lib/net/include/il_skel.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/include/il_skel.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 
Index: uspace/lib/net/include/netif_skel.h
===================================================================
--- uspace/lib/net/include/netif_skel.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/include/netif_skel.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 
Index: uspace/lib/net/include/nil_skel.h
===================================================================
--- uspace/lib/net/include/nil_skel.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/include/nil_skel.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 
Index: uspace/lib/net/include/tl_skel.h
===================================================================
--- uspace/lib/net/include/tl_skel.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/include/tl_skel.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <fibril_synch.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 
Index: uspace/lib/net/netif/netif_skel.c
===================================================================
--- uspace/lib/net/netif/netif_skel.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/netif/netif_skel.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <fibril_synch.h>
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/netif.h>
@@ -369,5 +368,5 @@
 	 * the initial IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
Index: uspace/lib/net/nil/nil_skel.c
===================================================================
--- uspace/lib/net/nil/nil_skel.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/nil/nil_skel.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -54,5 +54,5 @@
 	 * the initial IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -115,5 +115,5 @@
 		goto out;
 	
-	rc = ipc_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
+	rc = async_connect_to_me(PHONE_NS, service, 0, 0, NULL);
 	if (rc != EOK)
 		goto out;
Index: uspace/lib/net/tl/icmp_remote.c
===================================================================
--- uspace/lib/net/tl/icmp_remote.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/tl/icmp_remote.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,5 +42,4 @@
 #include <async.h>
 #include <errno.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/icmp.h>
Index: uspace/lib/net/tl/tl_skel.c
===================================================================
--- uspace/lib/net/tl/tl_skel.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/net/tl/tl_skel.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -54,5 +54,5 @@
 	 * the initial IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	/* Per-connection initialization */
@@ -117,5 +117,5 @@
 		goto out;
 	
-	rc = ipc_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
+	rc = async_connect_to_me(PHONE_NS, service, 0, 0, NULL);
 	if (rc != EOK)
 		goto out;
Index: uspace/lib/packet/generic/packet_server.c
===================================================================
--- uspace/lib/packet/generic/packet_server.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/packet/generic/packet_server.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -44,9 +44,6 @@
 #include <unistd.h>
 #include <sys/mman.h>
-
-#include <ipc/ipc.h>
 #include <ipc/packet.h>
 #include <ipc/net.h>
-
 #include <net/packet.h>
 #include <net/packet_header.h>
@@ -292,10 +289,10 @@
 
 	if (!async_share_in_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);
+		async_answer_0(callid, EINVAL);
 		return EINVAL;
 	}
 
 	if (size != packet->length) {
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return ENOMEM;
 	}
Index: uspace/lib/packet/include/packet_server.h
===================================================================
--- uspace/lib/packet/include/packet_server.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/packet/include/packet_server.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,5 +45,5 @@
 #define LIBPACKET_PACKET_SERVER_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 
 extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *,
Index: uspace/lib/usb/include/usb/descriptor.h
===================================================================
--- uspace/lib/usb/include/usb/descriptor.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/include/usb/descriptor.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define LIBUSB_DESCRIPTOR_H_
 
-#include <ipc/ipc.h>
 #include <async.h>
 
Index: uspace/lib/usb/include/usb/devreq.h
===================================================================
--- uspace/lib/usb/include/usb/devreq.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/include/usb/devreq.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 #define LIBUSB_DEVREQ_H_
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <usb/usb.h>
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/include/usb/usb.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,5 +38,4 @@
 #include <sys/types.h>
 #include <byteorder.h>
-#include <ipc/ipc.h>
 
 /** Convert 16bit value from native (host) endianness to USB endianness. */
Index: uspace/lib/usb/src/addrkeep.c
===================================================================
--- uspace/lib/usb/src/addrkeep.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/src/addrkeep.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,5 +33,5 @@
  * @brief Address keeping.
  */
-#include <usb/addrkeep.h>
+#include <usb/hcd.h>
 #include <errno.h>
 #include <assert.h>
Index: uspace/lib/usb/src/pipes.c
===================================================================
--- uspace/lib/usb/src/pipes.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/src/pipes.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -90,5 +90,5 @@
 
 leave:
-	ipc_hangup(hc_phone);
+	async_hangup(hc_phone);
 	return rc;
 }
@@ -211,5 +211,5 @@
 	}
 
-	int rc = ipc_hangup(pipe->hc_phone);
+	int rc = async_hangup(pipe->hc_phone);
 	if (rc != EOK) {
 		return rc;
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/src/recognise.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -33,4 +33,5 @@
  * @brief Functions for recognising kind of attached devices.
  */
+#include <sys/types.h>
 #include <usb_iface.h>
 #include <usb/usbdrv.h>
Index: uspace/lib/usb/src/usbdrv.c
===================================================================
--- uspace/lib/usb/src/usbdrv.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usb/src/usbdrv.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -80,5 +80,5 @@
 	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
 
-	ipc_hangup(parent_phone);
+	async_hangup(parent_phone);
 
 	if (rc != EOK) {
Index: uspace/lib/usbvirt/src/callback.c
===================================================================
--- uspace/lib/usbvirt/src/callback.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usbvirt/src/callback.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -54,15 +54,15 @@
 	
 	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
+		async_answer_0(iid, EADDRNOTAVAIL);
 		return;
 	}
 	
 	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
 	
 	if (expected_len == 0) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -74,5 +74,5 @@
 		
 	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return;
 	}
@@ -80,5 +80,5 @@
 	rc = device->transaction_setup(device, endpoint, buffer, len);
 	
-	ipc_answer_0(iid, rc);
+	async_answer_0(iid, rc);
 }
 
@@ -92,10 +92,10 @@
 	
 	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
+		async_answer_0(iid, EADDRNOTAVAIL);
 		return;
 	}
 	
 	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -111,5 +111,5 @@
 			
 		if (rc != EOK) {
-			ipc_answer_0(iid, rc);
+			async_answer_0(iid, rc);
 			return;
 		}
@@ -122,5 +122,5 @@
 	}
 	
-	ipc_answer_0(iid, rc);
+	async_answer_0(iid, rc);
 }
 
@@ -135,10 +135,10 @@
 	
 	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
+		async_answer_0(iid, EADDRNOTAVAIL);
 		return;
 	}
 	
 	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -157,5 +157,5 @@
 		ipc_callid_t callid;
 		if (!async_data_read_receive(&callid, &receive_len)) {
-			ipc_answer_0(iid, EINVAL);
+			async_answer_0(iid, EINVAL);
 			return;
 		}
@@ -166,5 +166,5 @@
 	}
 	
-	ipc_answer_1(iid, rc, len);
+	async_answer_1(iid, rc, len);
 }
 
@@ -174,5 +174,5 @@
 {
 	if (device->name == NULL) {
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 	}
 	
@@ -182,5 +182,5 @@
 	size_t accepted_size;
 	if (!async_data_read_receive(&callid, &accepted_size)) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -191,5 +191,5 @@
 	async_data_read_finalize(callid, device->name, accepted_size);
 	
-	ipc_answer_1(iid, EOK, accepted_size);
+	async_answer_1(iid, EOK, accepted_size);
 }
 
@@ -197,5 +197,5 @@
 void device_callback_connection(usbvirt_device_t *device, ipc_callid_t iid, ipc_call_t *icall)
 {
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -206,5 +206,5 @@
 		switch (IPC_GET_IMETHOD(call)) {
 			case IPC_M_PHONE_HUNGUP:
-				ipc_answer_0(callid, EOK);
+				async_answer_0(callid, EOK);
 				return;
 			
@@ -226,5 +226,5 @@
 			
 			default:
-				ipc_answer_0(callid, EINVAL);
+				async_answer_0(callid, EINVAL);
 				break;
 		}
Index: uspace/lib/usbvirt/src/main.c
===================================================================
--- uspace/lib/usbvirt/src/main.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/lib/usbvirt/src/main.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -159,5 +159,5 @@
 {
 	if (dev->vhcd_phone > 0) {
-		ipc_hangup(dev->vhcd_phone);
+		async_hangup(dev->vhcd_phone);
 	}
 	
@@ -173,5 +173,5 @@
 	virtual_device_t *dev = find_device_by_id(0);
 	if (dev == NULL) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		printf("Ooops\n");
 		return;
@@ -220,7 +220,5 @@
 	}
 	
-	sysarg_t phonehash;
-	sysarg_t taskhash;
-	rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &taskhash, &phonehash);
+	rc = async_connect_to_me(hcd_phone, 0, 0, 0, callback_connection);
 	if (rc != EOK) {
 		printf("ipc_connect_to_me() failed\n");
@@ -233,6 +231,4 @@
 	virtual_device->vhcd_phone = hcd_phone;
 	virtual_device->id = 0;
-	
-	async_new_connection(taskhash, phonehash, 0, NULL, callback_connection);
 	
 	return EOK;
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -51,9 +51,9 @@
 #include <libarch/ddi.h>
 #include <ddi.h>
-#include <ipc/ipc.h>
 #include <ipc/bd.h>
 #include <async.h>
 #include <as.h>
 #include <fibril_synch.h>
+#include <stdint.h>
 #include <str.h>
 #include <devmap.h>
@@ -62,4 +62,5 @@
 #include <errno.h>
 #include <bool.h>
+#include <byteorder.h>
 #include <task.h>
 #include <macros.h>
@@ -74,6 +75,9 @@
 #define LEGACY_CTLS 4
 
-/** Physical block size. Should be always 512. */
-static const size_t block_size = 512;
+/**
+ * Size of data returned from Identify Device or Identify Packet Device
+ * command.
+ */
+static const size_t identify_data_size = 512;
 
 /** Size of the communication area. */
@@ -106,10 +110,16 @@
 static int ata_bd_write_blocks(int disk_id, uint64_t ba, size_t cnt,
     const void *buf);
-static int ata_bd_read_block(int disk_id, uint64_t ba, size_t cnt,
+static int ata_rcmd_read(int disk_id, uint64_t ba, size_t cnt,
     void *buf);
-static int ata_bd_write_block(int disk_id, uint64_t ba, size_t cnt,
+static int ata_rcmd_write(int disk_id, uint64_t ba, size_t cnt,
     const void *buf);
 static int disk_init(disk_t *d, int disk_id);
 static int drive_identify(int drive_id, void *buf);
+static int identify_pkt_dev(int dev_idx, void *buf);
+static int ata_cmd_packet(int dev_idx, const void *cpkt, size_t cpkt_size,
+    void *obuf, size_t obuf_size);
+static int ata_pcmd_inquiry(int dev_idx, void *obuf, size_t obuf_size);
+static int ata_pcmd_read_12(int dev_idx, uint64_t ba, size_t cnt,
+    void *obuf, size_t obuf_size);
 static void disk_print_summary(disk_t *d);
 static int coord_calc(disk_t *d, uint64_t ba, block_coord_t *bc);
@@ -204,15 +214,20 @@
 	printf("%s: ", d->model);
 
-	switch (d->amode) {
-	case am_chs:
-		printf("CHS %u cylinders, %u heads, %u sectors",
-		    disk->geom.cylinders, disk->geom.heads, disk->geom.sectors);
-		break;
-	case am_lba28:
-		printf("LBA-28");
-		break;
-	case am_lba48:
-		printf("LBA-48");
-		break;
+	if (d->dev_type == ata_reg_dev) {
+		switch (d->amode) {
+		case am_chs:
+			printf("CHS %u cylinders, %u heads, %u sectors",
+			    disk->geom.cylinders, disk->geom.heads,
+			    disk->geom.sectors);
+			break;
+		case am_lba28:
+			printf("LBA-28");
+			break;
+		case am_lba48:
+			printf("LBA-48");
+			break;
+		}
+	} else {
+		printf("PACKET");
 	}
 
@@ -266,5 +281,5 @@
 	sysarg_t method;
 	devmap_handle_t dh;
-	int flags;
+	unsigned int flags;
 	int retval;
 	uint64_t ba;
@@ -282,13 +297,13 @@
 
 	if (disk_id < 0 || disk[disk_id].present == false) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	if (!async_share_out_receive(&callid, &comm_size, &flags)) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -296,5 +311,5 @@
 	fs_va = as_get_mappable_page(comm_size);
 	if (fs_va == NULL) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -308,5 +323,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -314,5 +329,5 @@
 			    IPC_GET_ARG2(call));
 			cnt = IPC_GET_ARG3(call);
-			if (cnt * block_size > comm_size) {
+			if (cnt * disk[disk_id].block_size > comm_size) {
 				retval = ELIMIT;
 				break;
@@ -324,5 +339,5 @@
 			    IPC_GET_ARG2(call));
 			cnt = IPC_GET_ARG3(call);
-			if (cnt * block_size > comm_size) {
+			if (cnt * disk[disk_id].block_size > comm_size) {
 				retval = ELIMIT;
 				break;
@@ -331,8 +346,8 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, disk[disk_id].block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
-			ipc_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks),
+			async_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks),
 			    UPPER32(disk[disk_id].blocks));
 			continue;
@@ -341,5 +356,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
@@ -354,4 +369,5 @@
 	identify_data_t idata;
 	uint8_t model[40];
+	ata_inquiry_data_t inq_data;
 	uint16_t w;
 	uint8_t c;
@@ -360,11 +376,42 @@
 	unsigned i;
 
+	d->present = false;
+	fibril_mutex_initialize(&d->lock);
+
+	/* Try identify command. */
 	rc = drive_identify(disk_id, &idata);
-	if (rc != EOK) {
-		d->present = false;
-		return rc;
-	}
-
-	if ((idata.caps & cap_lba) == 0) {
+	if (rc == EOK) {
+		/* Success. It's a register (non-packet) device. */
+		printf("ATA register-only device found.\n");
+		d->dev_type = ata_reg_dev;
+	} else if (rc == EIO) {
+		/*
+		 * There is something, but not a register device.
+		 * It could be a packet device.
+		 */
+		rc = identify_pkt_dev(disk_id, &idata);
+		if (rc == EOK) {
+			/* We have a packet device. */
+			d->dev_type = ata_pkt_dev;
+		} else {
+			/* Nope. Something's there, but not recognized. */
+			return EIO;
+		}
+	} else {
+		/* Operation timed out. That means there is no device there. */
+		return EIO;
+	}
+
+	printf("device caps: 0x%04x\n", idata.caps);
+	if (d->dev_type == ata_pkt_dev) {
+		/* Packet device */
+		d->amode = 0;
+
+		d->geom.cylinders = 0;
+		d->geom.heads = 0;
+		d->geom.sectors = 0;
+
+		d->blocks = 0;
+	} else if ((idata.caps & rd_cap_lba) == 0) {
 		/* Device only supports CHS addressing. */
 		d->amode = am_chs;
@@ -423,7 +470,25 @@
 	d->model[pos] = '\0';
 
+	if (d->dev_type == ata_pkt_dev) {
+		/* Send inquiry. */
+		rc = ata_pcmd_inquiry(0, &inq_data, sizeof(inq_data));
+		if (rc != EOK) {
+			printf("Device inquiry failed.\n");
+			d->present = false;
+			return EIO;
+		}
+
+		/* Check device type. */
+		if (INQUIRY_PDEV_TYPE(inq_data.pdev_type) != PDEV_TYPE_CDROM)
+			printf("Warning: Peripheral device type is not CD-ROM.\n");
+
+		/* Assume 2k block size for now. */
+		d->block_size = 2048;
+	} else {
+		/* Assume register Read always uses 512-byte blocks. */
+		d->block_size = 512;
+	}
+
 	d->present = true;
-	fibril_mutex_initialize(&d->lock);
-
 	return EOK;
 }
@@ -436,5 +501,10 @@
 
 	while (cnt > 0) {
-		rc = ata_bd_read_block(disk_id, ba, 1, buf);
+		if (disk[disk_id].dev_type == ata_reg_dev)
+			rc = ata_rcmd_read(disk_id, ba, 1, buf);
+		else
+			rc = ata_pcmd_read_12(disk_id, ba, 1, buf,
+			    disk[disk_id].block_size);
+
 		if (rc != EOK)
 			return rc;
@@ -442,5 +512,5 @@
 		++ba;
 		--cnt;
-		buf += block_size;
+		buf += disk[disk_id].block_size;
 	}
 
@@ -454,6 +524,9 @@
 	int rc;
 
+	if (disk[disk_id].dev_type != ata_reg_dev)
+		return ENOTSUP;
+
 	while (cnt > 0) {
-		rc = ata_bd_write_block(disk_id, ba, 1, buf);
+		rc = ata_rcmd_write(disk_id, ba, 1, buf);
 		if (rc != EOK)
 			return rc;
@@ -461,5 +534,5 @@
 		++ba;
 		--cnt;
-		buf += block_size;
+		buf += disk[disk_id].block_size;
 	}
 
@@ -474,4 +547,7 @@
  * @param disk_id	Device ID, 0 or 1.
  * @param buf		Pointer to a 512-byte buffer.
+ *
+ * @return		ETIMEOUT on timeout (this can mean the device is
+ *			not present). EIO if device responds with error.
  */
 static int drive_identify(int disk_id, void *buf)
@@ -485,5 +561,5 @@
 
 	if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
-		return EIO;
+		return ETIMEOUT;
 
 	pio_write_8(&cmd->drive_head, drv_head);
@@ -494,15 +570,15 @@
 	 */
 	if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
-		return EIO;
+		return ETIMEOUT;
 
 	pio_write_8(&cmd->command, CMD_IDENTIFY_DRIVE);
 
 	if (wait_status(0, ~SR_BSY, &status, TIMEOUT_PROBE) != EOK)
-		return EIO;
+		return ETIMEOUT;
 
 	/* Read data from the disk buffer. */
 
 	if ((status & SR_DRQ) != 0) {
-		for (i = 0; i < block_size / 2; i++) {
+		for (i = 0; i < identify_data_size / 2; i++) {
 			data = pio_read_16(&cmd->data_port);
 			((uint16_t *) buf)[i] = data;
@@ -510,6 +586,204 @@
 	}
 
+	if ((status & SR_ERR) != 0) {
+		return EIO;
+	}
+
+	return EOK;
+}
+
+/** Issue Identify Packet Device command.
+ *
+ * Reads @c identify data into the provided buffer. This is used to detect
+ * whether an ATAPI device is present and if so, to determine its parameters.
+ *
+ * @param dev_idx	Device index, 0 or 1.
+ * @param buf		Pointer to a 512-byte buffer.
+ */
+static int identify_pkt_dev(int dev_idx, void *buf)
+{
+	uint16_t data;
+	uint8_t status;
+	uint8_t drv_head;
+	size_t i;
+
+	drv_head = ((dev_idx != 0) ? DHR_DRV : 0);
+
+	if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
+		return EIO;
+
+	pio_write_8(&cmd->drive_head, drv_head);
+
+	/* For ATAPI commands we do not need to wait for DRDY. */
+	if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
+		return EIO;
+
+	pio_write_8(&cmd->command, CMD_IDENTIFY_PKT_DEV);
+
+	if (wait_status(0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK)
+		return EIO;
+
+	/* Read data from the device buffer. */
+
+	if ((status & SR_DRQ) != 0) {
+		for (i = 0; i < identify_data_size / 2; i++) {
+			data = pio_read_16(&cmd->data_port);
+			((uint16_t *) buf)[i] = data;
+		}
+	}
+
 	if ((status & SR_ERR) != 0)
 		return EIO;
+
+	return EOK;
+}
+
+/** Issue packet command (i. e. write a command packet to the device).
+ *
+ * Only data-in commands are supported (e.g. inquiry, read).
+ *
+ * @param dev_idx	Device index (0 or 1)
+ * @param obuf		Buffer for storing data read from device
+ * @param obuf_size	Size of obuf in bytes
+ *
+ * @return EOK on success, EIO on error.
+ */
+static int ata_cmd_packet(int dev_idx, const void *cpkt, size_t cpkt_size,
+    void *obuf, size_t obuf_size)
+{
+	size_t i;
+	uint8_t status;
+	uint8_t drv_head;
+	disk_t *d;
+	size_t data_size;
+	uint16_t val;
+
+	d = &disk[dev_idx];
+	fibril_mutex_lock(&d->lock);
+
+	/* New value for Drive/Head register */
+	drv_head =
+	    ((dev_idx != 0) ? DHR_DRV : 0);
+
+	if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	pio_write_8(&cmd->drive_head, drv_head);
+
+	if (wait_status(0, ~(SR_BSY|SR_DRQ), NULL, TIMEOUT_BSY) != EOK) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	/* Byte count <- max. number of bytes we can read in one transfer. */
+	pio_write_8(&cmd->cylinder_low, 0xfe);
+	pio_write_8(&cmd->cylinder_high, 0xff);
+
+	pio_write_8(&cmd->command, CMD_PACKET);
+
+	if (wait_status(SR_DRQ, ~SR_BSY, &status, TIMEOUT_BSY) != EOK) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	/* Write command packet. */
+	for (i = 0; i < (cpkt_size + 1) / 2; i++)
+		pio_write_16(&cmd->data_port, ((uint16_t *) cpkt)[i]);
+
+	if (wait_status(0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	if ((status & SR_DRQ) == 0) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	/* Read byte count. */
+	data_size = (uint16_t) pio_read_8(&cmd->cylinder_low) +
+	    ((uint16_t) pio_read_8(&cmd->cylinder_high) << 8);
+
+	/* Check whether data fits into output buffer. */
+	if (data_size > obuf_size) {
+		/* Output buffer is too small to store data. */
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	/* Read data from the device buffer. */
+	for (i = 0; i < (data_size + 1) / 2; i++) {
+		val = pio_read_16(&cmd->data_port);
+		((uint16_t *) obuf)[i] = val;
+	}
+
+	if (status & SR_ERR) {
+		fibril_mutex_unlock(&d->lock);
+		return EIO;
+	}
+
+	fibril_mutex_unlock(&d->lock);
+
+	return EOK;
+}
+
+/** Issue ATAPI Inquiry.
+ *
+ * @param dev_idx	Device index (0 or 1)
+ * @param obuf		Buffer for storing inquiry data read from device
+ * @param obuf_size	Size of obuf in bytes
+ *
+ * @return EOK on success, EIO on error.
+ */
+static int ata_pcmd_inquiry(int dev_idx, void *obuf, size_t obuf_size)
+{
+	ata_pcmd_inquiry_t cp;
+	int rc;
+
+	memset(&cp, 0, sizeof(cp));
+
+	cp.opcode = PCMD_INQUIRY;
+	cp.alloc_len = min(obuf_size, 0xff); /* Allocation length */
+
+	rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size);
+	if (rc != EOK)
+		return rc;
+
+	return EOK;
+}
+
+/** Issue ATAPI read(12) command.
+ *
+ * Output buffer must be large enough to hold the data, otherwise the
+ * function will fail.
+ *
+ * @param dev_idx	Device index (0 or 1)
+ * @param ba		Starting block address
+ * @param cnt		Number of blocks to read
+ * @param obuf		Buffer for storing inquiry data read from device
+ * @param obuf_size	Size of obuf in bytes
+ *
+ * @return EOK on success, EIO on error.
+ */
+static int ata_pcmd_read_12(int dev_idx, uint64_t ba, size_t cnt,
+    void *obuf, size_t obuf_size)
+{
+	ata_pcmd_read_12_t cp;
+	int rc;
+
+	if (ba > UINT32_MAX)
+		return EINVAL;
+
+	memset(&cp, 0, sizeof(cp));
+
+	cp.opcode = PCMD_READ_12;
+	cp.ba = host2uint32_t_be(ba);
+	cp.nblocks = host2uint32_t_be(cnt);
+
+	rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size);
+	if (rc != EOK)
+		return rc;
 
 	return EOK;
@@ -525,5 +799,5 @@
  * @return EOK on success, EIO on error.
  */
-static int ata_bd_read_block(int disk_id, uint64_t ba, size_t blk_cnt,
+static int ata_rcmd_read(int disk_id, uint64_t ba, size_t blk_cnt,
     void *buf)
 {
@@ -580,5 +854,5 @@
 		/* Read data from the device buffer. */
 
-		for (i = 0; i < block_size / 2; i++) {
+		for (i = 0; i < disk[disk_id].block_size / 2; i++) {
 			data = pio_read_16(&cmd->data_port);
 			((uint16_t *) buf)[i] = data;
@@ -602,5 +876,5 @@
  * @return EOK on success, EIO on error.
  */
-static int ata_bd_write_block(int disk_id, uint64_t ba, size_t cnt,
+static int ata_rcmd_write(int disk_id, uint64_t ba, size_t cnt,
     const void *buf)
 {
@@ -656,5 +930,5 @@
 		/* Write data to the device buffer. */
 
-		for (i = 0; i < block_size / 2; i++) {
+		for (i = 0; i < disk[disk_id].block_size / 2; i++) {
 			pio_write_16(&cmd->data_port, ((uint16_t *) buf)[i]);
 		}
Index: uspace/srv/bd/ata_bd/ata_bd.h
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/ata_bd/ata_bd.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -53,6 +53,11 @@
 };
 
-/** Block addressing mode. */
-enum addr_mode {
+enum ata_dev_type {
+	ata_reg_dev,	/* Register device (no packet feature set support) */
+	ata_pkt_dev	/* Packet device (supports packet feature set). */
+};
+
+/** Register device block addressing mode. */
+enum rd_addr_mode {
 	am_chs,		/**< CHS block addressing */
 	am_lba28,	/**< LBA-28 block addressing */
@@ -62,6 +67,5 @@
 /** Block coordinates */
 typedef struct {
-	/** Addressing mode used */
-	enum addr_mode amode;
+	enum rd_addr_mode amode;
 
 	union {
@@ -90,5 +94,10 @@
 typedef struct {
 	bool present;
-	enum addr_mode amode;
+
+	/** Device type */
+	enum ata_dev_type dev_type;
+
+	/** Addressing mode to use (if register device) */
+	enum rd_addr_mode amode;
 
 	/*
@@ -102,4 +111,5 @@
 
 	uint64_t blocks;
+	size_t block_size;
 
 	char model[STR_BOUNDS(40) + 1];
Index: uspace/srv/bd/ata_bd/ata_hw.h
===================================================================
--- uspace/srv/bd/ata_bd/ata_hw.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/ata_bd/ata_hw.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -134,8 +134,10 @@
 	CMD_WRITE_SECTORS	= 0x30,
 	CMD_WRITE_SECTORS_EXT	= 0x34,
+	CMD_PACKET		= 0xA0,
+	CMD_IDENTIFY_PKT_DEV	= 0xA1,
 	CMD_IDENTIFY_DRIVE	= 0xEC
 };
 
-/** Data returned from @c identify command. */
+/** Data returned from identify device and identify packet device command. */
 typedef struct {
 	uint16_t gen_conf;
@@ -159,5 +161,5 @@
 	uint16_t max_rw_multiple;
 	uint16_t _res48;
-	uint16_t caps;
+	uint16_t caps;		/* Different meaning for packet device */
 	uint16_t _res50;
 	uint16_t pio_timing;
@@ -214,9 +216,22 @@
 } identify_data_t;
 
-enum ata_caps {
-	cap_iordy	= 0x0800,
-	cap_iordy_cbd	= 0x0400,
-	cap_lba		= 0x0200,
-	cap_dma		= 0x0100
+/** Capability bits for register device. */
+enum ata_regdev_caps {
+	rd_cap_iordy		= 0x0800,
+	rd_cap_iordy_cbd	= 0x0400,
+	rd_cap_lba		= 0x0200,
+	rd_cap_dma		= 0x0100
+};
+
+/** Capability bits for packet device. */
+enum ata_pktdev_caps {
+	pd_cap_ildma		= 0x8000,
+	pd_cap_cmdqueue		= 0x4000,
+	pd_cap_overlap		= 0x2000,
+	pd_cap_need_softreset	= 0x1000,	/* Obsolete (ATAPI-6) */
+	pd_cap_iordy		= 0x0800,
+	pd_cap_iordy_dis	= 0x0400,
+	pd_cap_lba		= 0x0200,	/* Must be on */
+	pd_cap_dma		= 0x0100
 };
 
@@ -226,4 +241,56 @@
 };
 
+/** ATA packet command codes. */
+enum ata_pkt_command {
+	PCMD_INQUIRY		= 0x12,
+	PCMD_READ_12		= 0xa8
+};
+
+/** ATAPI Inquiry command */
+typedef struct {
+	uint8_t opcode;		/**< Operation code (PCMD_INQUIRY) */
+	uint8_t _res0;
+	uint8_t _res1;
+	uint8_t _res2;
+	uint8_t alloc_len;	/**< Allocation length */
+	uint8_t _res3;
+	uint8_t _res4;
+	uint8_t _res5;
+	uint32_t _res6;
+} __attribute__ ((packed)) ata_pcmd_inquiry_t;
+
+/** ATAPI Read(12) command */
+typedef struct {
+	uint8_t opcode;		/**< Operation code (PCMD_READ_12) */
+	uint8_t _res0;
+	uint32_t ba;		/**< Starting block address */
+	uint32_t nblocks;	/**< Number of blocks to transfer */
+	uint8_t _res1;
+	uint8_t _res2;
+} __attribute__ ((packed)) ata_pcmd_read_12_t;
+
+/** Data returned from Inquiry command (mandatory part) */
+typedef struct {
+	uint8_t pdev_type;	/** Reserved, Peripheral device type */
+	uint8_t rmb;		/** RMB, Reserved */
+	uint8_t std_version;	/** ISO version, ECMA version, ANSI version */
+	uint8_t atapi_ver_rdf;	/** ATAPI version, Response data format */
+	uint8_t additional_len;	/** Additional length */
+	uint8_t _res0;
+	uint8_t _res1;
+	uint8_t _res2;
+	uint8_t vendor_id[8];	/** Vendor ID */
+	uint8_t product_id[8];	/** Product ID */
+	uint8_t product_rev[4];	/** Product revision level */
+} ata_inquiry_data_t;
+
+/** Extract value of ata_inquiry_data_t.pdev_type */
+#define INQUIRY_PDEV_TYPE(val) ((val) & 0x1f)
+
+/** Values for ata_inquiry_data_t.pdev_type */
+enum ata_pdev_type {
+	PDEV_TYPE_CDROM		= 0x05
+};
+
 #endif
 
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <ipc/bd.h>
 #include <async.h>
@@ -178,5 +177,5 @@
 	sysarg_t method;
 	size_t comm_size;
-	int flags;
+	unsigned int flags;
 	int retval;
 	uint64_t ba;
@@ -184,8 +183,8 @@
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	if (!async_share_out_receive(&callid, &comm_size, &flags)) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -193,5 +192,5 @@
 	fs_va = as_get_mappable_page(comm_size);
 	if (fs_va == NULL) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -205,5 +204,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -228,8 +227,8 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
-			ipc_answer_2(callid, EOK, LOWER32(num_blocks),
+			async_answer_2(callid, EOK, LOWER32(num_blocks),
 			    UPPER32(num_blocks));
 			continue;
@@ -238,5 +237,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #include <libarch/ddi.h>
 #include <ddi.h>
-#include <ipc/ipc.h>
 #include <ipc/bd.h>
 #include <async.h>
@@ -161,5 +160,5 @@
 	sysarg_t method;
 	devmap_handle_t dh;
-	int flags;
+	unsigned int flags;
 	int retval;
 	uint64_t ba;
@@ -177,18 +176,18 @@
 
 	if (disk_id < 0) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	if (!async_share_out_receive(&callid, &comm_size, &flags)) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
 
 	if (comm_size < block_size) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -196,5 +195,5 @@
 	fs_va = as_get_mappable_page(comm_size);
 	if (fs_va == NULL) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -208,5 +207,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -231,5 +230,5 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
@@ -240,5 +239,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -47,5 +47,4 @@
 #include <stdlib.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <ipc/bd.h>
 #include <async.h>
@@ -316,5 +315,5 @@
 	sysarg_t method;
 	devmap_handle_t dh;
-	int flags;
+	unsigned int flags;
 	int retval;
 	aoff64_t ba;
@@ -335,5 +334,5 @@
 
 	if (part == NULL) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -342,8 +341,8 @@
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	if (!async_share_out_receive(&callid, &comm_size, &flags)) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -351,5 +350,5 @@
 	fs_va = as_get_mappable_page(comm_size);
 	if (fs_va == NULL) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -363,5 +362,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -386,8 +385,8 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
-			ipc_answer_2(callid, EOK, LOWER32(part->length),
+			async_answer_2(callid, EOK, LOWER32(part->length),
 			    UPPER32(part->length));
 			continue;
@@ -396,5 +395,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -57,5 +57,4 @@
 #include <stdlib.h>
 #include <unistd.h>
-#include <ipc/ipc.h>
 #include <ipc/bd.h>
 #include <async.h>
@@ -394,5 +393,5 @@
 	sysarg_t method;
 	devmap_handle_t dh;
-	int flags;
+	unsigned int flags;
 	int retval;
 	uint64_t ba;
@@ -413,5 +412,5 @@
 
 	if (part == NULL) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -420,8 +419,8 @@
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	if (!async_share_out_receive(&callid, &comm_size, &flags)) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -429,5 +428,5 @@
 	fs_va = as_get_mappable_page(comm_size);
 	if (fs_va == NULL) {
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -441,5 +440,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -464,8 +463,8 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
-			ipc_answer_2(callid, EOK, LOWER32(part->length),
+			async_answer_2(callid, EOK, LOWER32(part->length),
 			    UPPER32(part->length));
 			continue;
@@ -474,5 +473,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/bd/rd/rd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/ns.h>
@@ -98,10 +97,10 @@
 	 * Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	/*
 	 * Now we wait for the client to send us its communication as_area.
 	 */
-	int flags;
+	unsigned int flags;
 	if (async_share_out_receive(&callid, &comm_size, &flags)) {
 		fs_va = as_get_mappable_page(comm_size);
@@ -109,5 +108,5 @@
 			(void) async_share_out_finalize(callid, fs_va);
 		} else {
-			ipc_answer_0(callid, EHANGUP);
+			async_answer_0(callid, EHANGUP);
 			return;
 		}
@@ -118,5 +117,5 @@
 		 * Close the connection.
 		 */
-		ipc_answer_0(callid, EHANGUP);
+		async_answer_0(callid, EHANGUP);
 		return;
 	}
@@ -130,5 +129,5 @@
 			 * Answer the message and exit the fibril.
 			 */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case BD_READ_BLOCKS:
@@ -153,8 +152,8 @@
 			break;
 		case BD_GET_BLOCK_SIZE:
-			ipc_answer_1(callid, EOK, block_size);
+			async_answer_1(callid, EOK, block_size);
 			continue;
 		case BD_GET_NUM_BLOCKS:
-			ipc_answer_2(callid, EOK, LOWER32(rd_size / block_size),
+			async_answer_2(callid, EOK, LOWER32(rd_size / block_size),
 			    UPPER32(rd_size / block_size));
 			continue;
@@ -169,5 +168,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/clip/clip.c
===================================================================
--- uspace/srv/clip/clip.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/clip/clip.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -29,6 +29,6 @@
 #include <stdio.h>
 #include <bool.h>
-#include <ipc/ipc.h>
 #include <async.h>
+#include <ipc/ns.h>
 #include <ipc/services.h>
 #include <ipc/clipboard.h>
@@ -62,10 +62,10 @@
 		
 		fibril_mutex_unlock(&clip_mtx);
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		break;
 	case CLIPBOARD_TAG_DATA:
 		rc = async_data_write_accept((void **) &data, false, 0, 0, 0, &size);
 		if (rc != EOK) {
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			break;
 		}
@@ -81,8 +81,8 @@
 		
 		fibril_mutex_unlock(&clip_mtx);
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		break;
 	default:
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 	}
 }
@@ -99,6 +99,6 @@
 	case CLIPBOARD_TAG_DATA:
 		if (!async_data_read_receive(&callid, &size)) {
-			ipc_answer_0(callid, EINVAL);
-			ipc_answer_0(rid, EINVAL);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
 			break;
 		}
@@ -106,6 +106,6 @@
 		if (clip_tag != CLIPBOARD_TAG_DATA) {
 			/* So far we only understand binary data */
-			ipc_answer_0(callid, EOVERFLOW);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(callid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			break;
 		}
@@ -113,6 +113,6 @@
 		if (clip_size != size) {
 			/* The client expects different size of data */
-			ipc_answer_0(callid, EOVERFLOW);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(callid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			break;
 		}
@@ -120,9 +120,9 @@
 		sysarg_t retval = async_data_read_finalize(callid, clip_data, size);
 		if (retval != EOK) {
-			ipc_answer_0(rid, retval);
+			async_answer_0(rid, retval);
 			break;
 		}
 		
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 	default:
 		/*
@@ -130,5 +130,5 @@
 		 * data from the clipbard
 		 */
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		break;
 	}
@@ -145,5 +145,5 @@
 	
 	fibril_mutex_unlock(&clip_mtx);
-	ipc_answer_2(rid, EOK, (sysarg_t) size, (sysarg_t) tag);
+	async_answer_2(rid, EOK, (sysarg_t) size, (sysarg_t) tag);
 }
 
@@ -151,5 +151,5 @@
 {
 	/* Accept connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	bool cont = true;
@@ -172,5 +172,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOENT);
+			async_answer_0(callid, ENOENT);
 		}
 	}
@@ -183,5 +183,5 @@
 	async_set_client_connection(clip_connection);
 	
-	if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, NULL, NULL)) 
+	if (service_register(SERVICE_CLIPBOARD) != EOK)
 		return -1;
 	
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/devman/devman.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -598,5 +598,5 @@
 	}
 
-	ipc_hangup(phone);
+	async_hangup(phone);
 
 	/*
@@ -795,5 +795,5 @@
 		if (phone >= 0) {
 			add_device(phone, drv, node, tree);
-			ipc_hangup(phone);
+			async_hangup(phone);
 		}
 	}
@@ -1071,7 +1071,7 @@
 	if (info != NULL) {
 		memset(info, 0, sizeof(dev_class_info_t));
-		list_initialize(&info->dev_classes);
-		list_initialize(&info->devmap_link);
-		list_initialize(&info->link);
+		link_initialize(&info->dev_classes);
+		link_initialize(&info->devmap_link);
+		link_initialize(&info->link);
 	}
 	
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/devman/devman.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <adt/list.h>
 #include <adt/hash_table.h>
-#include <ipc/ipc.h>
 #include <ipc/devman.h>
 #include <ipc/devmap.h>
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/devman/main.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -75,5 +75,5 @@
 	iid = async_get_call(&icall);
 	if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) {
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
 		return NULL;
 	}
@@ -84,5 +84,5 @@
 	int rc = async_data_write_accept((void **) &drv_name, true, 0, 0, 0, 0);
 	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return NULL;
 	}
@@ -98,5 +98,5 @@
 		free(drv_name);
 		drv_name = NULL;
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return NULL;
 	}
@@ -110,6 +110,6 @@
 	ipc_callid_t callid = async_get_call(&call);
 	if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
-		ipc_answer_0(callid, ENOTSUP);
-		ipc_answer_0(iid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
+		async_answer_0(iid, ENOTSUP);
 		return NULL;
 	}
@@ -121,6 +121,6 @@
 	    driver->name);
 	
-	ipc_answer_0(callid, EOK);
-	ipc_answer_0(iid, EOK);
+	async_answer_0(callid, EOK);
+	async_answer_0(iid, EOK);
 	
 	return driver;
@@ -144,5 +144,5 @@
 		printf(NAME ": ERROR: devman_receive_match_id - invalid "
 		    "protocol.\n");
-		ipc_answer_0(callid, EINVAL); 
+		async_answer_0(callid, EINVAL); 
 		delete_match_id(match_id);
 		return EINVAL;
@@ -152,9 +152,9 @@
 		printf(NAME ": ERROR: devman_receive_match_id - failed to "
 		    "allocate match id.\n");
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return ENOMEM;
 	}
 	
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 	
 	match_id->score = IPC_GET_ARG1(call);
@@ -219,5 +219,5 @@
 	if (parent == NULL) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
-		ipc_answer_0(callid, ENOENT);
+		async_answer_0(callid, ENOENT);
 		return;
 	}
@@ -227,5 +227,5 @@
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		return;
 	}
@@ -235,5 +235,5 @@
 		fibril_rwlock_write_unlock(&tree->rwlock);
 		delete_dev_node(node);
-		ipc_answer_0(callid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
 		return;
 	}
@@ -264,5 +264,5 @@
 
 	/* Return device handle to parent's driver. */
-	ipc_answer_1(callid, EOK, node->handle);
+	async_answer_1(callid, EOK, node->handle);
 }
 
@@ -302,5 +302,5 @@
 	    0, 0, 0, 0);
 	if (rc != EOK) {
-		ipc_answer_0(callid, rc);
+		async_answer_0(callid, rc);
 		return;
 	}	
@@ -308,5 +308,5 @@
 	node_t *dev = find_dev_node(&device_tree, handle);
 	if (dev == NULL) {
-		ipc_answer_0(callid, ENOENT);
+		async_answer_0(callid, ENOENT);
 		return;
 	}
@@ -321,5 +321,5 @@
 	    "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
 
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 }
 
@@ -343,5 +343,5 @@
 {
 	/* Accept the connection. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	driver_t *driver = devman_driver_register();
@@ -379,5 +379,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, EINVAL); 
+			async_answer_0(callid, EINVAL); 
 			break;
 		}
@@ -393,5 +393,5 @@
 	int rc = async_data_write_accept((void **) &pathname, true, 0, 0, 0, 0);
 	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return;
 	}
@@ -402,9 +402,9 @@
 
 	if (dev == NULL) {
-		ipc_answer_0(iid, ENOENT);
-		return;
-	}
-	
-	ipc_answer_1(iid, EOK, dev->handle);
+		async_answer_0(iid, ENOENT);
+		return;
+	}
+	
+	async_answer_1(iid, EOK, dev->handle);
 }
 
@@ -414,5 +414,5 @@
 {
 	/* Accept connection. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	bool cont = true;
@@ -429,5 +429,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOENT);
+			async_answer_0(callid, ENOENT);
 		}
 	}
@@ -443,5 +443,5 @@
 		printf(NAME ": devman_forward error - no device with handle %" PRIun
 		    " was found.\n", handle);
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -461,5 +461,5 @@
 		    " (%s) is not in usable state.\n",
 		    handle, dev->pathname);
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -475,11 +475,11 @@
 		    driver->name);
 		printf("the driver's phone is %" PRIun ").\n", driver->phone);
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-
-//	printf(NAME ": devman_forward: forward connection to device %s to "
-//	    "driver %s.\n", dev->pathname, driver->name);
-	ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+
+	printf(NAME ": devman_forward: forward connection to device %s to "
+	    "driver %s.\n", dev->pathname, driver->name);
+	async_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
 }
 
@@ -496,14 +496,14 @@
 	
 	if (dev == NULL || dev->drv == NULL) {
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
 	
 	if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
 	    IPC_FF_NONE);
 	printf(NAME ": devman_connection_devmapper: forwarded connection to "
@@ -536,5 +536,5 @@
 	default:
 		/* No such interface */
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 	}
 }
@@ -587,5 +587,5 @@
 
 	/* Register device manager at naming service. */
-	if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, NULL, NULL) != 0)
+	if (service_register(SERVICE_DEVMAN) != EOK)
 		return -1;
 
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/devmap/devmap.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -374,5 +374,5 @@
 	
 	if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
 		return NULL;
 	}
@@ -381,5 +381,5 @@
 	    (devmap_driver_t *) malloc(sizeof(devmap_driver_t));
 	if (driver == NULL) {
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return NULL;
 	}
@@ -392,5 +392,5 @@
 	if (rc != EOK) {
 		free(driver);
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return NULL;
 	}
@@ -405,11 +405,11 @@
 		free(driver->name);
 		free(driver);
-		ipc_answer_0(callid, ENOTSUP);
-		ipc_answer_0(iid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
+		async_answer_0(iid, ENOTSUP);
 		return NULL;
 	}
 	
 	driver->phone = IPC_GET_ARG5(call);
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 	
 	/*
@@ -423,5 +423,6 @@
 	 */
 	list_initialize(&driver->devices);
-	list_initialize(&(driver->drivers));
+
+	link_initialize(&driver->drivers);
 	
 	fibril_mutex_lock(&drivers_list_mutex);
@@ -438,5 +439,5 @@
 	fibril_mutex_unlock(&drivers_list_mutex);
 	
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	return driver;
@@ -456,5 +457,5 @@
 	
 	if (driver->phone != 0)
-		ipc_hangup(driver->phone);
+		async_hangup(driver->phone);
 	
 	/* Remove it from list of drivers */
@@ -491,5 +492,5 @@
 {
 	if (driver == NULL) {
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
 		return;
 	}
@@ -499,5 +500,5 @@
 	    (devmap_device_t *) malloc(sizeof(devmap_device_t));
 	if (device == NULL) {
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return;
 	}
@@ -512,5 +513,5 @@
 	if (rc != EOK) {
 		free(device);
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return;
 	}
@@ -520,5 +521,5 @@
 		free(fqdn);
 		free(device);
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -534,10 +535,10 @@
 		free(device->name);
 		free(device);
-		ipc_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	list_initialize(&(device->devices));
-	list_initialize(&(device->driver_devices));
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	link_initialize(&device->devices);
+	link_initialize(&device->driver_devices);
 	
 	/* Check that device is not already registered */
@@ -549,5 +550,5 @@
 		free(device->name);
 		free(device);
-		ipc_answer_0(iid, EEXISTS);
+		async_answer_0(iid, EEXISTS);
 		return;
 	}
@@ -571,5 +572,5 @@
 	fibril_mutex_unlock(&devices_list_mutex);
 	
-	ipc_answer_1(iid, EOK, device->handle);
+	async_answer_1(iid, EOK, device->handle);
 }
 
@@ -602,14 +603,14 @@
 	if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, ENOENT);
+		async_answer_0(callid, ENOENT);
 		return;
 	}
 	
 	if (dev->forward_interface == 0) {
-		ipc_forward_fast(callid, dev->driver->phone,
+		async_forward_fast(callid, dev->driver->phone,
 		    dev->handle, 0, 0,
 		    IPC_FF_NONE);
 	} else {
-		ipc_forward_fast(callid, dev->driver->phone,
+		async_forward_fast(callid, dev->driver->phone,
 		    dev->forward_interface, dev->handle, 0,
 		    IPC_FF_NONE);
@@ -633,5 +634,5 @@
 	    DEVMAP_NAME_MAXLEN, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return;
 	}
@@ -641,5 +642,5 @@
 	if (!devmap_fqdn_split(fqdn, &ns_name, &name)) {
 		free(fqdn);
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -668,5 +669,5 @@
 		}
 		
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		free(ns_name);
 		free(name);
@@ -675,5 +676,5 @@
 	}
 	
-	ipc_answer_1(iid, EOK, dev->handle);
+	async_answer_1(iid, EOK, dev->handle);
 	
 	fibril_mutex_unlock(&devices_list_mutex);
@@ -696,5 +697,5 @@
 	    DEVMAP_NAME_MAXLEN, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
+		async_answer_0(iid, rc);
 		return;
 	}
@@ -721,5 +722,5 @@
 		}
 		
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		free(name);
 		fibril_mutex_unlock(&devices_list_mutex);
@@ -727,5 +728,5 @@
 	}
 	
-	ipc_answer_1(iid, EOK, namespace->handle);
+	async_answer_1(iid, EOK, namespace->handle);
 	
 	fibril_mutex_unlock(&devices_list_mutex);
@@ -743,9 +744,9 @@
 		    devmap_device_find_handle(IPC_GET_ARG1(*icall));
 		if (dev == NULL)
-			ipc_answer_1(iid, EOK, DEV_HANDLE_NONE);
+			async_answer_1(iid, EOK, DEV_HANDLE_NONE);
 		else
-			ipc_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
+			async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
 	} else
-		ipc_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
+		async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
 	
 	fibril_mutex_unlock(&devices_list_mutex);
@@ -755,5 +756,5 @@
 {
 	fibril_mutex_lock(&devices_list_mutex);
-	ipc_answer_1(iid, EOK, list_count(&namespaces_list));
+	async_answer_1(iid, EOK, list_count(&namespaces_list));
 	fibril_mutex_unlock(&devices_list_mutex);
 }
@@ -766,7 +767,7 @@
 	    devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
 	if (namespace == NULL)
-		ipc_answer_0(iid, EEXISTS);
+		async_answer_0(iid, EEXISTS);
 	else
-		ipc_answer_1(iid, EOK, namespace->refcnt);
+		async_answer_1(iid, EOK, namespace->refcnt);
 	
 	fibril_mutex_unlock(&devices_list_mutex);
@@ -778,12 +779,12 @@
 	size_t size;
 	if (!async_data_read_receive(&callid, &size)) {
-		ipc_answer_0(callid, EREFUSED);
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(callid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
 		return;
 	}
 	
 	if ((size % sizeof(dev_desc_t)) != 0) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -794,6 +795,6 @@
 	if (count != list_count(&namespaces_list)) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, EOVERFLOW);
-		ipc_answer_0(iid, EOVERFLOW);
+		async_answer_0(callid, EOVERFLOW);
+		async_answer_0(iid, EOVERFLOW);
 		return;
 	}
@@ -802,6 +803,6 @@
 	if (desc == NULL) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, ENOMEM);
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return;
 	}
@@ -824,5 +825,5 @@
 	fibril_mutex_unlock(&devices_list_mutex);
 	
-	ipc_answer_0(iid, retval);
+	async_answer_0(iid, retval);
 }
 
@@ -835,12 +836,12 @@
 	size_t size;
 	if (!async_data_read_receive(&callid, &size)) {
-		ipc_answer_0(callid, EREFUSED);
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(callid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
 		return;
 	}
 	
 	if ((size % sizeof(dev_desc_t)) != 0) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
@@ -852,6 +853,6 @@
 	if (namespace == NULL) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, ENOENT);
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(callid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -860,6 +861,6 @@
 	if (count != namespace->refcnt) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, EOVERFLOW);
-		ipc_answer_0(iid, EOVERFLOW);
+		async_answer_0(callid, EOVERFLOW);
+		async_answer_0(iid, EOVERFLOW);
 		return;
 	}
@@ -868,6 +869,6 @@
 	if (desc == NULL) {
 		fibril_mutex_unlock(&devices_list_mutex);
-		ipc_answer_0(callid, ENOMEM);
-		ipc_answer_0(iid, EREFUSED);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(iid, EREFUSED);
 		return;
 	}
@@ -891,5 +892,5 @@
 	fibril_mutex_unlock(&devices_list_mutex);
 	
-	ipc_answer_0(iid, retval);
+	async_answer_0(iid, retval);
 }
 
@@ -910,5 +911,5 @@
 	if (!fnd) {
 		fibril_mutex_unlock(&null_devices_mutex);
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return;
 	}
@@ -920,5 +921,5 @@
 	if (dev_name == NULL) {
 		fibril_mutex_unlock(&null_devices_mutex);
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return;
 	}
@@ -928,5 +929,5 @@
 	if (device == NULL) {
 		fibril_mutex_unlock(&null_devices_mutex);
-		ipc_answer_0(iid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
 		return;
 	}
@@ -938,10 +939,10 @@
 		fibril_mutex_lock(&devices_list_mutex);
 		fibril_mutex_unlock(&null_devices_mutex);
-		ipc_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	list_initialize(&(device->devices));
-	list_initialize(&(device->driver_devices));
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	link_initialize(&device->devices);
+	link_initialize(&device->driver_devices);
 	
 	/* Get unique device handle */
@@ -960,5 +961,5 @@
 	fibril_mutex_unlock(&null_devices_mutex);
 	
-	ipc_answer_1(iid, EOK, (sysarg_t) i);
+	async_answer_1(iid, EOK, (sysarg_t) i);
 }
 
@@ -967,5 +968,5 @@
 	sysarg_t i = IPC_GET_ARG1(*icall);
 	if (i >= NULL_DEVICES) {
-		ipc_answer_0(iid, ELIMIT);
+		async_answer_0(iid, ELIMIT);
 		return;
 	}
@@ -975,5 +976,5 @@
 	if (null_devices[i] == NULL) {
 		fibril_mutex_unlock(&null_devices_mutex);
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -986,5 +987,5 @@
 	
 	fibril_mutex_unlock(&null_devices_mutex);
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 }
 
@@ -1012,5 +1013,5 @@
 {
 	/* Accept connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	devmap_driver_t *driver = devmap_driver_register();
@@ -1029,7 +1030,7 @@
 		case DEVMAP_DRIVER_UNREGISTER:
 			if (NULL == driver)
-				ipc_answer_0(callid, ENOENT);
+				async_answer_0(callid, ENOENT);
 			else
-				ipc_answer_0(callid, EOK);
+				async_answer_0(callid, EOK);
 			break;
 		case DEVMAP_DEVICE_REGISTER:
@@ -1048,5 +1049,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOENT);
+			async_answer_0(callid, ENOENT);
 		}
 	}
@@ -1067,5 +1068,5 @@
 {
 	/* Accept connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	bool cont = true;
@@ -1106,5 +1107,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOENT);
+			async_answer_0(callid, ENOENT);
 		}
 	}
@@ -1130,5 +1131,5 @@
 	default:
 		/* No such interface */
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 	}
 }
@@ -1150,5 +1151,5 @@
 	
 	/* Register device mapper at naming service */
-	if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, NULL, NULL) != 0)
+	if (service_register(SERVICE_DEVMAP) != EOK)
 		return -1;
 	
Index: uspace/srv/fs/devfs/devfs.c
===================================================================
--- uspace/srv/fs/devfs/devfs.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/devfs/devfs.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,6 +40,6 @@
 
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <async.h>
 #include <errno.h>
@@ -62,5 +62,5 @@
 {
 	if (iid)
-		ipc_answer_0(iid, EOK);
+		async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -111,5 +111,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOTSUP);
+			async_answer_0(callid, ENOTSUP);
 			break;
 		}
@@ -126,5 +126,5 @@
 	}
 	
-	int vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0);
+	int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
 	if (vfs_phone < EOK) {
 		printf(NAME ": Unable to connect to VFS\n");
Index: uspace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/devfs/devfs_ops.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <macros.h>
 #include <bool.h>
@@ -131,4 +130,5 @@
 {
 	devfs_node_t *node = (devfs_node_t *) pfn->data;
+	int ret;
 	
 	if (node->handle == 0) {
@@ -146,6 +146,7 @@
 				
 				if (str_cmp(devs[pos].name, component) == 0) {
+					ret = devfs_node_get_internal(rfn, DEV_HANDLE_NAMESPACE, devs[pos].handle);
 					free(devs);
-					return devfs_node_get_internal(rfn, DEV_HANDLE_NAMESPACE, devs[pos].handle);
+					return ret;
 				}
 			}
@@ -163,6 +164,7 @@
 				for (pos = 0; pos < count; pos++) {
 					if (str_cmp(devs[pos].name, component) == 0) {
+						ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
 						free(devs);
-						return devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
+						return ret;
 					}
 				}
@@ -185,6 +187,7 @@
 			for (pos = 0; pos < count; pos++) {
 				if (str_cmp(devs[pos].name, component) == 0) {
+					ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
 					free(devs);
-					return devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
+					return ret;
 				}
 			}
@@ -465,10 +468,10 @@
 	    0, NULL);
 	if (retval != EOK) {
-		ipc_answer_0(rid, retval);
+		async_answer_0(rid, retval);
 		return;
 	}
 	
 	free(opts);
-	ipc_answer_3(rid, EOK, 0, 0, 0);
+	async_answer_3(rid, EOK, 0, 0, 0);
 }
 
@@ -480,5 +483,5 @@
 void devfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
 {
-	ipc_answer_0(rid, ENOTSUP);
+	async_answer_0(rid, ENOTSUP);
 }
 
@@ -513,6 +516,6 @@
 		size_t size;
 		if (!async_data_read_receive(&callid, &size)) {
-			ipc_answer_0(callid, EINVAL);
-			ipc_answer_0(rid, EINVAL);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
 			return;
 		}
@@ -535,5 +538,5 @@
 			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
 			free(desc);
-			ipc_answer_1(rid, EOK, 1);
+			async_answer_1(rid, EOK, 1);
 			return;
 		}
@@ -550,5 +553,5 @@
 				async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
 				free(desc);
-				ipc_answer_1(rid, EOK, 1);
+				async_answer_1(rid, EOK, 1);
 				return;
 			}
@@ -557,6 +560,6 @@
 		}
 		
-		ipc_answer_0(callid, ENOENT);
-		ipc_answer_1(rid, ENOENT, 0);
+		async_answer_0(callid, ENOENT);
+		async_answer_1(rid, ENOENT, 0);
 		return;
 	}
@@ -569,6 +572,6 @@
 		size_t size;
 		if (!async_data_read_receive(&callid, &size)) {
-			ipc_answer_0(callid, EINVAL);
-			ipc_answer_0(rid, EINVAL);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
 			return;
 		}
@@ -580,11 +583,11 @@
 			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
 			free(desc);
-			ipc_answer_1(rid, EOK, 1);
+			async_answer_1(rid, EOK, 1);
 			return;
 		}
 		
 		free(desc);
-		ipc_answer_0(callid, ENOENT);
-		ipc_answer_1(rid, ENOENT, 0);
+		async_answer_0(callid, ENOENT);
+		async_answer_1(rid, ENOENT, 0);
 		return;
 	}
@@ -601,5 +604,5 @@
 		if (lnk == NULL) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			return;
 		}
@@ -611,6 +614,6 @@
 		if (!async_data_read_receive(&callid, NULL)) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(callid, EINVAL);
-			ipc_answer_0(rid, EINVAL);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
 			return;
 		}
@@ -623,5 +626,5 @@
 		
 		/* Forward the IPC_M_DATA_READ request to the driver */
-		ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+		async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 		fibril_mutex_unlock(&devices_mutex);
 		
@@ -632,9 +635,9 @@
 		
 		/* Driver reply is the final result of the whole operation */
-		ipc_answer_1(rid, rc, bytes);
-		return;
-	}
-	
-	ipc_answer_0(rid, ENOENT);
+		async_answer_1(rid, rc, bytes);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
 }
 
@@ -643,5 +646,5 @@
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	if (index == 0) {
-		ipc_answer_0(rid, ENOTSUP);
+		async_answer_0(rid, ENOTSUP);
 		return;
 	}
@@ -651,5 +654,5 @@
 	if (type == DEV_HANDLE_NAMESPACE) {
 		/* Namespace directory */
-		ipc_answer_0(rid, ENOTSUP);
+		async_answer_0(rid, ENOTSUP);
 		return;
 	}
@@ -665,5 +668,5 @@
 		if (lnk == NULL) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			return;
 		}
@@ -675,6 +678,6 @@
 		if (!async_data_write_receive(&callid, NULL)) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(callid, EINVAL);
-			ipc_answer_0(rid, EINVAL);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
 			return;
 		}
@@ -687,5 +690,5 @@
 		
 		/* Forward the IPC_M_DATA_WRITE request to the driver */
-		ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+		async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 		
 		fibril_mutex_unlock(&devices_mutex);
@@ -697,14 +700,14 @@
 		
 		/* Driver reply is the final result of the whole operation */
-		ipc_answer_1(rid, rc, bytes);
-		return;
-	}
-	
-	ipc_answer_0(rid, ENOENT);
+		async_answer_1(rid, rc, bytes);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
 }
 
 void devfs_truncate(ipc_callid_t rid, ipc_call_t *request)
 {
-	ipc_answer_0(rid, ENOTSUP);
+	async_answer_0(rid, ENOTSUP);
 }
 
@@ -714,5 +717,5 @@
 	
 	if (index == 0) {
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return;
 	}
@@ -722,5 +725,5 @@
 	if (type == DEV_HANDLE_NAMESPACE) {
 		/* Namespace directory */
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return;
 	}
@@ -735,5 +738,5 @@
 		if (lnk == NULL) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			return;
 		}
@@ -744,5 +747,5 @@
 		
 		if (dev->refcount == 0) {
-			ipc_hangup(dev->phone);
+			async_hangup(dev->phone);
 			hash_table_remove(&devices, key, DEVICES_KEYS);
 		}
@@ -750,9 +753,9 @@
 		fibril_mutex_unlock(&devices_mutex);
 		
-		ipc_answer_0(rid, EOK);
-		return;
-	}
-	
-	ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
 }
 
@@ -762,5 +765,5 @@
 	
 	if (index == 0) {
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return;
 	}
@@ -770,5 +773,5 @@
 	if (type == DEV_HANDLE_NAMESPACE) {
 		/* Namespace directory */
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return;
 	}
@@ -783,5 +786,5 @@
 		if (lnk == NULL) {
 			fibril_mutex_unlock(&devices_mutex);
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			return;
 		}
@@ -802,14 +805,14 @@
 		
 		/* Driver reply is the final result of the whole operation */
-		ipc_answer_0(rid, rc);
-		return;
-	}
-	
-	ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, rc);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
 }
 
 void devfs_destroy(ipc_callid_t rid, ipc_call_t *request)
 {
-	ipc_answer_0(rid, ENOTSUP);
+	async_answer_0(rid, ENOTSUP);
 }
 
Index: uspace/srv/fs/devfs/devfs_ops.h
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/devfs/devfs_ops.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,5 @@
 #define DEVFS_DEVFS_OPS_H_
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
 #include <bool.h>
 
Index: uspace/srv/fs/fat/fat.c
===================================================================
--- uspace/srv/fs/fat/fat.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/fat/fat.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,6 +38,6 @@
 
 #include "fat.h"
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <async.h>
 #include <errno.h>
@@ -84,5 +84,5 @@
 		 * created by IPC_M_CONNECT_TO_ME.
 		 */
-		ipc_answer_0(iid, EOK);
+		async_answer_0(iid, EOK);
 	}
 	
@@ -136,5 +136,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOTSUP);
+			async_answer_0(callid, ENOTSUP);
 			break;
 		}
@@ -153,5 +153,5 @@
 		goto err;
 
-	vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0);
+	vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
 	if (vfs_phone < EOK) {
 		printf(NAME ": failed to connect to VFS\n");
Index: uspace/srv/fs/fat/fat.h
===================================================================
--- uspace/srv/fs/fat/fat.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/fat/fat.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
 
 #include "fat_fat.h"
-#include <ipc/ipc.h>
 #include <fibril_synch.h>
 #include <libfs.h>
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/fat/fat_ops.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,5 +42,4 @@
 #include <libfs.h>
 #include <libblock.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/devmap.h>
@@ -955,5 +954,5 @@
 	
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -970,5 +969,5 @@
 	rc = block_init(devmap_handle, BS_SIZE);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -978,5 +977,5 @@
 	if (rc != EOK) {
 		block_fini(devmap_handle);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -987,5 +986,5 @@
 	if (BPS(bs) != BS_SIZE) {
 		block_fini(devmap_handle);
-		ipc_answer_0(rid, ENOTSUP);
+		async_answer_0(rid, ENOTSUP);
 		return;
 	}
@@ -995,5 +994,5 @@
 	if (rc != EOK) {
 		block_fini(devmap_handle);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1004,5 +1003,5 @@
 		(void) block_cache_fini(devmap_handle);
 		block_fini(devmap_handle);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1012,5 +1011,5 @@
 		(void) block_cache_fini(devmap_handle);
 		block_fini(devmap_handle);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1022,5 +1021,5 @@
 		block_fini(devmap_handle);
 		fat_idx_fini_by_devmap_handle(devmap_handle);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -1032,5 +1031,5 @@
 		block_fini(devmap_handle);
 		fat_idx_fini_by_devmap_handle(devmap_handle);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -1044,5 +1043,5 @@
 		block_fini(devmap_handle);
 		fat_idx_fini_by_devmap_handle(devmap_handle);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -1062,5 +1061,5 @@
 	fibril_mutex_unlock(&ridxp->lock);
 
-	ipc_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt);
+	async_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt);
 }
 
@@ -1079,5 +1078,5 @@
 	rc = fat_root_get(&fn, devmap_handle);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1090,5 +1089,5 @@
 	if (nodep->refcnt != 2) {
 		(void) fat_node_put(fn);
-		ipc_answer_0(rid, EBUSY);
+		async_answer_0(rid, EBUSY);
 		return;
 	}
@@ -1110,5 +1109,5 @@
 	block_fini(devmap_handle);
 
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -1138,9 +1137,9 @@
 	rc = fat_node_get(&fn, devmap_handle, index);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
 	if (!fn) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1151,6 +1150,6 @@
 	if (!async_data_read_receive(&callid, &len)) {
 		fat_node_put(fn);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -1175,6 +1174,6 @@
 			if (rc != EOK) {
 				fat_node_put(fn);
-				ipc_answer_0(callid, rc);
-				ipc_answer_0(rid, rc);
+				async_answer_0(callid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -1184,5 +1183,5 @@
 			if (rc != EOK) {
 				fat_node_put(fn);
-				ipc_answer_0(rid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -1241,12 +1240,12 @@
 miss:
 		rc = fat_node_put(fn);
-		ipc_answer_0(callid, rc != EOK ? rc : ENOENT);
-		ipc_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
+		async_answer_0(callid, rc != EOK ? rc : ENOENT);
+		async_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
 		return;
 
 err:
 		(void) fat_node_put(fn);
-		ipc_answer_0(callid, rc);
-		ipc_answer_0(rid, rc);
+		async_answer_0(callid, rc);
+		async_answer_0(rid, rc);
 		return;
 
@@ -1257,5 +1256,5 @@
 
 	rc = fat_node_put(fn);
-	ipc_answer_1(rid, rc, (sysarg_t)bytes);
+	async_answer_1(rid, rc, (sysarg_t)bytes);
 }
 
@@ -1277,9 +1276,9 @@
 	rc = fat_node_get(&fn, devmap_handle, index);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
 	if (!fn) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1290,6 +1289,6 @@
 	if (!async_data_write_receive(&callid, &len)) {
 		(void) fat_node_put(fn);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -1319,6 +1318,6 @@
 		if (rc != EOK) {
 			(void) fat_node_put(fn);
-			ipc_answer_0(callid, rc);
-			ipc_answer_0(rid, rc);
+			async_answer_0(callid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1326,6 +1325,6 @@
 		if (rc != EOK) {
 			(void) fat_node_put(fn);
-			ipc_answer_0(callid, rc);
-			ipc_answer_0(rid, rc);
+			async_answer_0(callid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1336,5 +1335,5 @@
 		if (rc != EOK) {
 			(void) fat_node_put(fn);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1345,5 +1344,5 @@
 		size = nodep->size;
 		rc = fat_node_put(fn);
-		ipc_answer_2(rid, rc, bytes, nodep->size);
+		async_answer_2(rid, rc, bytes, nodep->size);
 		return;
 	} else {
@@ -1361,6 +1360,6 @@
 			/* could not allocate a chain of nclsts clusters */
 			(void) fat_node_put(fn);
-			ipc_answer_0(callid, rc);
-			ipc_answer_0(rid, rc);
+			async_answer_0(callid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1370,6 +1369,6 @@
 			(void) fat_free_clusters(bs, devmap_handle, mcl);
 			(void) fat_node_put(fn);
-			ipc_answer_0(callid, rc);
-			ipc_answer_0(rid, rc);
+			async_answer_0(callid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1379,6 +1378,6 @@
 			(void) fat_free_clusters(bs, devmap_handle, mcl);
 			(void) fat_node_put(fn);
-			ipc_answer_0(callid, rc);
-			ipc_answer_0(rid, rc);
+			async_answer_0(callid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1390,5 +1389,5 @@
 			(void) fat_free_clusters(bs, devmap_handle, mcl);
 			(void) fat_node_put(fn);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1401,5 +1400,5 @@
 			(void) fat_free_clusters(bs, devmap_handle, mcl);
 			(void) fat_node_put(fn);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -1407,5 +1406,5 @@
 		nodep->dirty = true;		/* need to sync node */
 		rc = fat_node_put(fn);
-		ipc_answer_2(rid, rc, bytes, size);
+		async_answer_2(rid, rc, bytes, size);
 		return;
 	}
@@ -1425,9 +1424,9 @@
 	rc = fat_node_get(&fn, devmap_handle, index);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
 	if (!fn) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1475,5 +1474,5 @@
 out:
 	fat_node_put(fn);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 	return;
 }
@@ -1481,5 +1480,5 @@
 void fat_close(ipc_callid_t rid, ipc_call_t *request)
 {
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -1493,14 +1492,14 @@
 	rc = fat_node_get(&fn, devmap_handle, index);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
 	if (!fn) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
 
 	rc = fat_destroy_node(fn);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -1523,9 +1522,9 @@
 	int rc = fat_node_get(&fn, devmap_handle, index);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
 	if (!fn) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1537,5 +1536,5 @@
 	
 	fat_node_put(fn);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
Index: uspace/srv/fs/tmpfs/tmpfs.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/tmpfs/tmpfs.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,6 +42,6 @@
 
 #include "tmpfs.h"
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <async.h>
 #include <errno.h>
@@ -90,5 +90,5 @@
 		 * created by IPC_M_CONNECT_TO_ME.
 		 */
-		ipc_answer_0(iid, EOK);
+		async_answer_0(iid, EOK);
 	}
 	
@@ -142,5 +142,5 @@
 			break;
 		default:
-			ipc_answer_0(callid, ENOTSUP);
+			async_answer_0(callid, ENOTSUP);
 			break;
 		}
@@ -157,5 +157,5 @@
 	}
 
-	int vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0);
+	int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
 	if (vfs_phone < EOK) {
 		printf(NAME ": Unable to connect to VFS\n");
Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
 #define TMPFS_TMPFS_H_
 
-#include <ipc/ipc.h>
 #include <libfs.h>
 #include <atomic.h>
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #include "tmpfs.h"
 #include "../../vfs/vfs.h"
-#include <ipc/ipc.h>
 #include <macros.h>
 #include <stdint.h>
@@ -450,5 +449,5 @@
 	rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -459,5 +458,5 @@
 		(void) tmpfs_node_put(rootfn);
 		free(opts);
-		ipc_answer_0(rid, EEXIST);
+		async_answer_0(rid, EEXIST);
 		return;
 	}
@@ -466,5 +465,5 @@
 	if (!tmpfs_instance_init(devmap_handle)) {
 		free(opts);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -475,10 +474,10 @@
 	if (str_cmp(opts, "restore") == 0) {
 		if (tmpfs_restore(devmap_handle))
-			ipc_answer_3(rid, EOK, rootp->index, rootp->size,
+			async_answer_3(rid, EOK, rootp->index, rootp->size,
 			    rootp->lnkcnt);
 		else
-			ipc_answer_0(rid, ELIMIT);
+			async_answer_0(rid, ELIMIT);
 	} else {
-		ipc_answer_3(rid, EOK, rootp->index, rootp->size,
+		async_answer_3(rid, EOK, rootp->index, rootp->size,
 		    rootp->lnkcnt);
 	}
@@ -496,5 +495,5 @@
 
 	tmpfs_instance_done(devmap_handle);
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -526,5 +525,5 @@
 	hlp = hash_table_find(&nodes, key);
 	if (!hlp) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -538,6 +537,6 @@
 	size_t size;
 	if (!async_data_read_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -566,6 +565,6 @@
 
 		if (lnk == &nodep->cs_head) {
-			ipc_answer_0(callid, ENOENT);
-			ipc_answer_1(rid, ENOENT, 0);
+			async_answer_0(callid, ENOENT);
+			async_answer_1(rid, ENOENT, 0);
 			return;
 		}
@@ -581,5 +580,5 @@
 	 * Answer the VFS_READ call.
 	 */
-	ipc_answer_1(rid, EOK, bytes);
+	async_answer_1(rid, EOK, bytes);
 }
 
@@ -601,5 +600,5 @@
 	hlp = hash_table_find(&nodes, key);
 	if (!hlp) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -613,6 +612,6 @@
 	size_t size;
 	if (!async_data_write_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);	
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);	
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -624,5 +623,5 @@
 		/* The file size is not changing. */
 		(void) async_data_write_finalize(callid, nodep->data + pos, size);
-		ipc_answer_2(rid, EOK, size, nodep->size);
+		async_answer_2(rid, EOK, size, nodep->size);
 		return;
 	}
@@ -637,6 +636,6 @@
 	void *newdata = realloc(nodep->data, nodep->size + delta);
 	if (!newdata) {
-		ipc_answer_0(callid, ENOMEM);
-		ipc_answer_2(rid, EOK, 0, nodep->size);
+		async_answer_0(callid, ENOMEM);
+		async_answer_2(rid, EOK, 0, nodep->size);
 		return;
 	}
@@ -646,5 +645,5 @@
 	nodep->data = newdata;
 	(void) async_data_write_finalize(callid, nodep->data + pos, size);
-	ipc_answer_2(rid, EOK, size, nodep->size);
+	async_answer_2(rid, EOK, size, nodep->size);
 }
 
@@ -665,5 +664,5 @@
 	link_t *hlp = hash_table_find(&nodes, key);
 	if (!hlp) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -672,10 +671,10 @@
 	
 	if (size == nodep->size) {
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return;
 	}
 	
 	if (size > SIZE_MAX) {
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -683,5 +682,5 @@
 	void *newdata = realloc(nodep->data, size);
 	if (!newdata) {
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -694,10 +693,10 @@
 	nodep->size = size;
 	nodep->data = newdata;
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
 void tmpfs_close(ipc_callid_t rid, ipc_call_t *request)
 {
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -715,5 +714,5 @@
 	hlp = hash_table_find(&nodes, key);
 	if (!hlp) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -721,5 +720,5 @@
 	    nh_link);
 	rc = tmpfs_destroy_node(FS_NODE(nodep));
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -740,5 +739,5 @@
 	 * thus the sync operation is a no-op.
 	 */
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
Index: uspace/srv/hid/adb_mouse/adb_dev.c
===================================================================
--- uspace/srv/hid/adb_mouse/adb_dev.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/adb_mouse/adb_dev.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/adb.h>
 #include <async.h>
@@ -68,13 +67,9 @@
 
 	/* NB: The callback connection is slotted for removal */
-	sysarg_t taskhash;
-	sysarg_t phonehash;
-	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
+	if (async_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
 		return false;
 	}
-
-	async_new_connection(taskhash, phonehash, 0, NULL, adb_dev_events);
-
+	
 	return 0;
 }
@@ -100,5 +95,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/adb_mouse/adb_mouse.c
===================================================================
--- uspace/srv/hid/adb_mouse/adb_mouse.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/adb_mouse/adb_mouse.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/mouse.h>
 #include <stdio.h>
@@ -98,5 +97,5 @@
 	int retval;
 
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -105,9 +104,9 @@
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
-				ipc_hangup(client_phone);
+				async_hangup(client_phone);
 				client_phone = -1;
 			}
 
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -122,5 +121,5 @@
 			retval = EINVAL;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/char_mouse/char_mouse.c
===================================================================
--- uspace/srv/hid/char_mouse/char_mouse.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/char_mouse/char_mouse.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/mouse.h>
 #include <stdio.h>
@@ -83,5 +82,5 @@
 	int retval;
 
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -90,9 +89,9 @@
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
-				ipc_hangup(client_phone);
+				async_hangup(client_phone);
 				client_phone = -1;
 			}
 
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -107,5 +106,5 @@
 			retval = EINVAL;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/char_mouse/chardev.c
===================================================================
--- uspace/srv/hid/char_mouse/chardev.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/char_mouse/chardev.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/char.h>
 #include <async.h>
@@ -70,12 +69,8 @@
 
 	/* NB: The callback connection is slotted for removal */
-	sysarg_t taskhash;
-	sysarg_t phonehash;
-	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
+	if (async_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
 		return false;
 	}
-
-	async_new_connection(taskhash, phonehash, 0, NULL, chardev_events);
 
 	return 0;
@@ -115,5 +110,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/console/console.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
 
 #include <libc.h>
-#include <ipc/ipc.h>
 #include <ipc/kbd.h>
 #include <io/keycode.h>
@@ -40,4 +39,5 @@
 #include <ipc/fb.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <errno.h>
 #include <ipc/console.h>
@@ -116,5 +116,5 @@
 static void curs_hide_sync(void)
 {
-	ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false); 
+	async_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false); 
 }
 
@@ -131,20 +131,20 @@
 static void screen_yield(void)
 {
-	ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD);
+	async_req_0_0(fb_info.phone, FB_SCREEN_YIELD);
 }
 
 static void screen_reclaim(void)
 {
-	ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
+	async_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
 }
 
 static void kbd_yield(void)
 {
-	ipc_call_sync_0_0(kbd_phone, KBD_YIELD);
+	async_req_0_0(kbd_phone, KBD_YIELD);
 }
 
 static void kbd_reclaim(void)
 {
-	ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM);
+	async_req_0_0(kbd_phone, KBD_RECLAIM);
 }
 
@@ -438,5 +438,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
@@ -474,5 +474,5 @@
 		}
 
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
@@ -485,5 +485,5 @@
 	
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -500,5 +500,5 @@
 	
 	gcons_notify_char(cons->index);
-	ipc_answer_1(rid, EOK, size);
+	async_answer_1(rid, EOK, size);
 	
 	free(buf);
@@ -510,6 +510,6 @@
 	size_t size;
 	if (!async_data_read_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -517,6 +517,6 @@
 	char *buf = (char *) malloc(size);
 	if (buf == NULL) {
-		ipc_answer_0(callid, ENOMEM);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -536,5 +536,5 @@
 	if (pos == size) {
 		(void) async_data_read_finalize(callid, buf, size);
-		ipc_answer_1(rid, EOK, size);
+		async_answer_1(rid, EOK, size);
 		free(buf);
 	} else {
@@ -554,5 +554,5 @@
 recheck:
 	if (keybuffer_pop(&cons->keybuffer, &ev)) {
-		ipc_answer_4(rid, EOK, ev.type, ev.key, ev.mods, ev.c);
+		async_answer_4(rid, EOK, ev.type, ev.key, ev.mods, ev.c);
 	} else {
 		fibril_condvar_wait(&input_cv, &input_mutex);
@@ -580,5 +580,5 @@
 	
 	if (cons == NULL) {
-		ipc_answer_0(iid, ENOENT);
+		async_answer_0(iid, ENOENT);
 		return;
 	}
@@ -599,5 +599,5 @@
 	
 	/* Accept the connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -659,5 +659,5 @@
 			rc = ccap_fb_to_con(fb_info.color_cap, &arg1);
 			if (rc != EOK) {
-				ipc_answer_0(callid, rc);
+				async_answer_0(callid, rc);
 				continue;
 			}
@@ -703,5 +703,5 @@
 			break;
 		}
-		ipc_answer_3(callid, EOK, arg1, arg2, arg3);
+		async_answer_3(callid, EOK, arg1, arg2, arg3);
 	}
 }
@@ -762,5 +762,5 @@
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
-		ipc_hangup(devmap_phone);
+		async_hangup(devmap_phone);
 		return retval;
 	}
@@ -769,5 +769,5 @@
 
 	if (retval != EOK) {
-		ipc_hangup(devmap_phone);
+		async_hangup(devmap_phone);
 		return retval;
 	}
@@ -775,5 +775,5 @@
 	devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(answer);
 
-	ipc_hangup(devmap_phone);
+	async_hangup(devmap_phone);
 
 	int phone = async_connect_me_to(PHONE_NS,
@@ -864,8 +864,6 @@
 	}
 	
-	sysarg_t taskhash;
-	sysarg_t phonehash;
-	if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &taskhash,
-	    &phonehash) != 0) {
+	if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)
+	    != 0) {
 		printf(NAME ": Failed to create callback from mouse device\n");
 		mouse_phone = -1;
@@ -873,9 +871,8 @@
 	}
 	
-	async_new_connection(taskhash, phonehash, 0, NULL, mouse_events);
 skip_mouse:
 	
 	/* Connect to framebuffer driver */
-	fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
+	fb_info.phone = service_connect_blocking(SERVICE_VIDEO, 0, 0);
 	if (fb_info.phone < 0) {
 		printf(NAME ": Failed to connect to video service\n");
@@ -953,8 +950,7 @@
 	
 	/* Receive kernel notifications */
+	async_set_interrupt_received(interrupt_received);
 	if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
 		printf(NAME ": Error registering kconsole notifications\n");
-	
-	async_set_interrupt_received(interrupt_received);
 	
 	/* Start fibril for checking on hot-plugged keyboards. */
Index: uspace/srv/hid/console/gcons.c
===================================================================
--- uspace/srv/hid/console/gcons.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/console/gcons.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,5 +34,4 @@
 
 #include <ipc/fb.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <stdio.h>
Index: uspace/srv/hid/fb/ega.c
===================================================================
--- uspace/srv/hid/fb/ega.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/fb/ega.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 #include <align.h>
 #include <async.h>
-#include <ipc/ipc.h>
 #include <errno.h>
 #include <stdio.h>
@@ -46,5 +45,4 @@
 #include <as.h>
 #include <ipc/fb.h>
-#include <ipc/ipc.h>
 #include <ipc/ns.h>
 #include <ipc/services.h>
@@ -262,5 +260,5 @@
 	
 	if (client_connected) {
-		ipc_answer_0(iid, ELIMIT);
+		async_answer_0(iid, ELIMIT);
 		return;
 	}
@@ -268,5 +266,5 @@
 	/* Accept connection */
 	client_connected = 1;
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -296,5 +294,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			client_connected = 0;
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			
 			/* Exit thread */
@@ -332,8 +330,8 @@
 			break;
 		case FB_GET_CSIZE:
-			ipc_answer_2(callid, EOK, scr_width, scr_height);
+			async_answer_2(callid, EOK, scr_width, scr_height);
 			continue;
 		case FB_GET_COLOR_CAP:
-			ipc_answer_1(callid, EOK, FB_CCAP_INDEXED);
+			async_answer_1(callid, EOK, FB_CCAP_INDEXED);
 			continue;
 		case FB_CLEAR:
@@ -440,5 +438,5 @@
 			retval = EINVAL;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/fb/fb.c
===================================================================
--- uspace/srv/hid/fb/fb.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/fb/fb.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -47,5 +47,4 @@
 #include <as.h>
 #include <ipc/fb.h>
-#include <ipc/ipc.h>
 #include <ipc/ns.h>
 #include <ipc/services.h>
@@ -1089,5 +1088,5 @@
 			void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
 			shm_size = IPC_GET_ARG2(*call);
-			if (ipc_answer_1(callid, EOK, (sysarg_t) dest)) {
+			if (async_answer_1(callid, EOK, (sysarg_t) dest)) {
 				shm_id = 0;
 				return false;
@@ -1166,5 +1165,5 @@
 	
 	if (handled)
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	return handled;
 }
@@ -1445,5 +1444,5 @@
 	}
 	if (handled)
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	return handled;
 }
@@ -1498,5 +1497,5 @@
 	
 	if (handled)
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	return handled;
 	
@@ -1582,5 +1581,5 @@
 	
 	if (client_connected) {
-		ipc_answer_0(iid, ELIMIT);
+		async_answer_0(iid, ELIMIT);
 		return;
 	}
@@ -1588,5 +1587,5 @@
 	/* Accept connection */
 	client_connected = true;
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -1641,5 +1640,5 @@
 				break;
 			}
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			
 			draw_char(vport, ch, col, row);
@@ -1674,8 +1673,8 @@
 			break;
 		case FB_GET_CSIZE:
-			ipc_answer_2(callid, EOK, vport->cols, vport->rows);
+			async_answer_2(callid, EOK, vport->cols, vport->rows);
 			continue;
 		case FB_GET_COLOR_CAP:
-			ipc_answer_1(callid, EOK, FB_CCAP_RGB);
+			async_answer_1(callid, EOK, FB_CCAP_RGB);
 			continue;
 		case FB_SCROLL:
@@ -1742,5 +1741,5 @@
 			break;
 		case FB_GET_RESOLUTION:
-			ipc_answer_2(callid, EOK, screen.xres, screen.yres);
+			async_answer_2(callid, EOK, screen.xres, screen.yres);
 			continue;
 		case FB_POINTER_MOVE:
@@ -1756,5 +1755,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/fb/main.c
===================================================================
--- uspace/srv/hid/fb/main.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/fb/main.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -27,6 +27,6 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <sysinfo.h>
 #include <async.h>
@@ -51,5 +51,5 @@
 	
 	dest = as_get_mappable_page(IPC_GET_ARG2(*call));
-	if (ipc_answer_1(callid, EOK, (sysarg_t) dest) == 0) {
+	if (async_answer_1(callid, EOK, (sysarg_t) dest) == 0) {
 		if (*area)
 			as_area_destroy(*area);
@@ -114,5 +114,5 @@
 		return -1;
 	
-	if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, NULL, NULL) != 0)
+	if (service_register(SERVICE_VIDEO) != EOK)
 		return -1;
 	
Index: uspace/srv/hid/fb/serial_console.c
===================================================================
--- uspace/srv/hid/fb/serial_console.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/fb/serial_console.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,4 @@
 
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <ipc/fb.h>
@@ -319,10 +318,10 @@
 	
 	if (client_connected) {
-		ipc_answer_0(iid, ELIMIT);
+		async_answer_0(iid, ELIMIT);
 		return;
 	}
 	
 	client_connected = 1;
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	/* Clear the terminal, set scrolling region
@@ -348,5 +347,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			client_connected = 0;
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			
 			/* Exit thread */
@@ -407,8 +406,8 @@
 			break;
 		case FB_GET_CSIZE:
-			ipc_answer_2(callid, EOK, scr_width, scr_height);
+			async_answer_2(callid, EOK, scr_width, scr_height);
 			continue;
 		case FB_GET_COLOR_CAP:
-			ipc_answer_1(callid, EOK, color ? FB_CCAP_INDEXED :
+			async_answer_1(callid, EOK, color ? FB_CCAP_INDEXED :
 			    FB_CCAP_STYLE);
 			continue;
@@ -478,5 +477,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/fb/serial_console.h
===================================================================
--- uspace/srv/hid/fb/serial_console.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/fb/serial_console.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,5 +39,6 @@
 #define FB_SERIAL_CONSOLE_H_
 
-#include <ipc/ipc.h>
+#include <sys/types.h>
+#include <ipc/common.h>
 
 typedef void (*putc_function_t)(char);
Index: uspace/srv/hid/kbd/generic/kbd.c
===================================================================
--- uspace/srv/hid/kbd/generic/kbd.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/generic/kbd.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/kbd.h>
@@ -173,5 +172,5 @@
 	int retval;
 
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -180,9 +179,9 @@
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
-				ipc_hangup(client_phone);
+				async_hangup(client_phone);
 				client_phone = -1;
 			}
 			
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -205,5 +204,5 @@
 			retval = EINVAL;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}	
 }
@@ -223,8 +222,6 @@
 	
 	if (cir_service) {
-		while (cir_phone < 0) {
-			cir_phone = ipc_connect_me_to_blocking(PHONE_NS, cir_service,
-			    0, 0);
-		}
+		while (cir_phone < 0)
+			cir_phone = service_connect_blocking(cir_service, 0, 0);
 	}
 	
Index: uspace/srv/hid/kbd/port/adb.c
===================================================================
--- uspace/srv/hid/kbd/port/adb.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/adb.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/adb.h>
 #include <async.h>
@@ -71,12 +70,8 @@
 
 	/* NB: The callback connection is slotted for removal */
-	sysarg_t taskhash;
-	sysarg_t phonehash;
-	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
+	if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
 		return false;
 	}
-
-	async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events);
 
 	return 0;
@@ -116,5 +111,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/kbd/port/chardev.c
===================================================================
--- uspace/srv/hid/kbd/port/chardev.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/chardev.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/char.h>
 #include <async.h>
@@ -91,12 +90,8 @@
 
 	/* NB: The callback connection is slotted for removal */
-	sysarg_t taskhash;
-	sysarg_t phonehash;
-	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) {
+	if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
 		return -1;
 	}
-
-	async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events);
 
 	return 0;
@@ -136,5 +131,5 @@
 			retval = ENOENT;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hid/kbd/port/gxemul.c
===================================================================
--- uspace/srv/hid/kbd/port/gxemul.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/gxemul.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <sysinfo.h>
@@ -74,5 +73,5 @@
 	async_set_interrupt_received(gxemul_irq_handler);
 	gxemul_cmds[0].addr = (void *) addr;
-	ipc_register_irq(inr, device_assign_devno(), 0, &gxemul_kbd);
+	register_irq(inr, device_assign_devno(), 0, &gxemul_kbd);
 	return 0;
 }
Index: uspace/srv/hid/kbd/port/msim.c
===================================================================
--- uspace/srv/hid/kbd/port/msim.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/msim.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <async.h>
 #include <sysinfo.h>
@@ -74,5 +73,5 @@
 	msim_cmds[0].addr = (void *) vaddr;
 	async_set_interrupt_received(msim_irq_handler);
-	ipc_register_irq(inr, device_assign_devno(), 0, &msim_kbd);
+	register_irq(inr, device_assign_devno(), 0, &msim_kbd);
 	
 	return 0;
Index: uspace/srv/hid/kbd/port/ns16550.c
===================================================================
--- uspace/srv/hid/kbd/port/ns16550.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/ns16550.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/irc.h>
 #include <async.h>
@@ -111,5 +110,5 @@
 	
 	async_set_interrupt_received(ns16550_irq_handler);
-	ipc_register_irq(inr, device_assign_devno(), inr, &ns16550_kbd);
+	register_irq(inr, device_assign_devno(), inr, &ns16550_kbd);
 	
 	return pio_enable((void *) ns16550_physical, 8, &vaddr);
Index: uspace/srv/hid/kbd/port/pl050.c
===================================================================
--- uspace/srv/hid/kbd/port/pl050.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/pl050.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 #include <ddi.h>
 #include <libarch/ddi.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <unistd.h>
@@ -101,5 +100,5 @@
 	
 	async_set_interrupt_received(pl050_irq_handler);
-	ipc_register_irq(inr, device_assign_devno(), 0, &pl050_kbd);
+	register_irq(inr, device_assign_devno(), 0, &pl050_kbd);
 	
 	return 0;
Index: uspace/srv/hid/kbd/port/z8530.c
===================================================================
--- uspace/srv/hid/kbd/port/z8530.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/kbd/port/z8530.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/irc.h>
 #include <async.h>
@@ -99,5 +98,5 @@
 	
 	async_set_interrupt_received(z8530_irq_handler);
-	ipc_register_irq(inr, device_assign_devno(), inr, &z8530_kbd);
+	register_irq(inr, device_assign_devno(), inr, &z8530_kbd);
 	
 	return 0;
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -42,5 +42,4 @@
 #include <io/console.h>
 #include <vfs/vfs.h>
-#include <ipc/ipc.h>
 #include <ipc/mouse.h>
 #include <async.h>
@@ -140,5 +139,5 @@
 
 	async_set_interrupt_received(s3c24xx_ts_irq_handler);
-	ipc_register_irq(inr, device_assign_devno(), 0, &ts_irq_code);
+	register_irq(inr, device_assign_devno(), 0, &ts_irq_code);
 
 	s3c24xx_ts_wait_for_int_mode(ts, updn_down);
@@ -377,5 +376,5 @@
 	int retval;
 
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -384,9 +383,9 @@
 		case IPC_M_PHONE_HUNGUP:
 			if (ts->client_phone != -1) {
-				ipc_hangup(ts->client_phone);
+				async_hangup(ts->client_phone);
 				ts->client_phone = -1;
 			}
 
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -401,5 +400,5 @@
 			retval = EINVAL;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -209,10 +209,10 @@
 
 	if (dev_addr < 0) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -222,5 +222,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -245,5 +245,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
@@ -276,5 +276,5 @@
 	cuda_irq_code.cmds[0].addr = (void *) &((cuda_t *) instance->cuda_kernel)->ifr;
 	async_set_interrupt_received(cuda_irq_handler);
-	ipc_register_irq(10, device_assign_devno(), 0, &cuda_irq_code);
+	register_irq(10, device_assign_devno(), 0, &cuda_irq_code);
 
 	/* Enable SR interrupt. */
Index: uspace/srv/hw/char/i8042/i8042.c
===================================================================
--- uspace/srv/hw/char/i8042/i8042.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/char/i8042/i8042.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <libarch/ddi.h>
 #include <devmap.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <unistd.h>
@@ -199,6 +198,6 @@
 	i8042_kbd.cmds[0].addr = (void *) &((i8042_t *) i8042_kernel)->status;
 	i8042_kbd.cmds[3].addr = (void *) &((i8042_t *) i8042_kernel)->data;
-	ipc_register_irq(inr_a, device_assign_devno(), 0, &i8042_kbd);
-	ipc_register_irq(inr_b, device_assign_devno(), 0, &i8042_kbd);
+	register_irq(inr_a, device_assign_devno(), 0, &i8042_kbd);
+	register_irq(inr_b, device_assign_devno(), 0, &i8042_kbd);
 	printf("%s: registered for interrupts %" PRIun " and %" PRIun "\n",
 	    NAME, inr_a, inr_b);
@@ -236,10 +235,10 @@
 
 	if (dev_id < 0) {
-		ipc_answer_0(iid, EINVAL);
+		async_answer_0(iid, EINVAL);
 		return;
 	}
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	printf(NAME ": accepted connection\n");
@@ -251,5 +250,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -272,5 +271,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <libarch/ddi.h>
 #include <devmap.h>
-#include <ipc/ipc.h>
 #include <ipc/char.h>
 #include <async.h>
@@ -119,5 +118,5 @@
 
 	/* Answer the IPC_M_CONNECT_ME_TO call. */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -127,5 +126,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* The other side has hung up. */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			return;
 		case IPC_M_CONNECT_TO_ME:
@@ -144,5 +143,5 @@
 			break;
 		}
-		ipc_answer_0(callid, retval);
+		async_answer_0(callid, retval);
 	}
 }
@@ -191,5 +190,5 @@
 	async_set_interrupt_received(s3c24xx_uart_irq_handler);
 
-	ipc_register_irq(inr, device_assign_devno(), 0, &uart_irq_code);
+	register_irq(inr, device_assign_devno(), 0, &uart_irq_code);
 
 	/* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */
Index: uspace/srv/hw/irc/apic/apic.c
===================================================================
--- uspace/srv/hw/irc/apic/apic.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/irc/apic/apic.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/irc.h>
@@ -75,5 +74,5 @@
 	 * Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -82,12 +81,12 @@
 		switch (IPC_GET_IMETHOD(call)) {
 		case IRC_ENABLE_INTERRUPT:
-			ipc_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call)));
+			async_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call)));
 			break;
 		case IRC_CLEAR_INTERRUPT:
 			/* Noop */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			break;
 		default:
-			ipc_answer_0(callid, EINVAL);
+			async_answer_0(callid, EINVAL);
 			break;
 		}
@@ -108,5 +107,5 @@
 	
 	async_set_client_connection(apic_connection);
-	ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, NULL, NULL);
+	service_register(SERVICE_APIC);
 	
 	return true;
Index: uspace/srv/hw/irc/fhc/fhc.c
===================================================================
--- uspace/srv/hw/irc/fhc/fhc.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/irc/fhc/fhc.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -29,12 +29,11 @@
 /** @addtogroup fhc
  * @{
- */ 
+ */
 
 /**
- * @file	fhc.c
- * @brief	FHC bus controller driver.
+ * @file fhc.c
+ * @brief FHC bus controller driver.
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/irc.h>
@@ -76,5 +75,5 @@
 	 * Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -85,5 +84,5 @@
 		case IRC_ENABLE_INTERRUPT:
 			/* Noop */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			break;
 		case IRC_CLEAR_INTERRUPT:
@@ -92,13 +91,13 @@
 			case FHC_UART_INR:
 				fhc_uart_virt[FHC_UART_ICLR] = 0;
-				ipc_answer_0(callid, EOK);
+				async_answer_0(callid, EOK);
 				break;
 			default:
-				ipc_answer_0(callid, ENOTSUP);
+				async_answer_0(callid, ENOTSUP);
 				break;
 			}
 			break;
 		default:
-			ipc_answer_0(callid, EINVAL);
+			async_answer_0(callid, EINVAL);
 			break;
 		}
@@ -137,5 +136,5 @@
 	
 	async_set_client_connection(fhc_connection);
-	ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, NULL, NULL);
+	service_register(SERVICE_FHC);
 	
 	return true;
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/irc.h>
@@ -109,5 +108,5 @@
 	 * Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
@@ -116,12 +115,12 @@
 		switch (IPC_GET_IMETHOD(call)) {
 		case IRC_ENABLE_INTERRUPT:
-			ipc_answer_0(callid, pic_enable_irq(IPC_GET_ARG1(call)));
+			async_answer_0(callid, pic_enable_irq(IPC_GET_ARG1(call)));
 			break;
 		case IRC_CLEAR_INTERRUPT:
 			/* Noop */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			break;
 		default:
-			ipc_answer_0(callid, EINVAL);
+			async_answer_0(callid, EINVAL);
 			break;
 		}
@@ -150,5 +149,5 @@
 	
 	async_set_client_connection(i8259_connection);
-	ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, NULL, NULL);
+	service_register(SERVICE_I8259);
 	
 	return true;
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/irc/obio/obio.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -27,11 +27,11 @@
  */
 
-/** @addtogroup obio 
+/** @addtogroup obio
  * @{
- */ 
+ */
 
 /**
- * @file	obio.c
- * @brief	OBIO driver.
+ * @file obio.c
+ * @brief OBIO driver.
  *
  * OBIO is a short for on-board I/O. On UltraSPARC IIi and systems with U2P,
@@ -42,5 +42,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/irc.h>
@@ -86,5 +85,5 @@
 	 * Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 
 	while (1) {
@@ -95,13 +94,13 @@
 		case IRC_ENABLE_INTERRUPT:
 			/* Noop */
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			break;
 		case IRC_CLEAR_INTERRUPT:
 			inr = IPC_GET_ARG1(call);
 			base_virt[OBIO_CIR(inr & INO_MASK)] = 0;
-			ipc_answer_0(callid, EOK);
+			async_answer_0(callid, EOK);
 			break;
 		default:
-			ipc_answer_0(callid, EINVAL);
+			async_answer_0(callid, EINVAL);
 			break;
 		}
@@ -138,5 +137,5 @@
 	
 	async_set_client_connection(obio_connection);
-	ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, NULL, NULL);
+	service_register(SERVICE_OBIO);
 	
 	return true;
Index: uspace/srv/hw/netif/ne2000/ne2000.c
===================================================================
--- uspace/srv/hw/netif/ne2000/ne2000.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/hw/netif/ne2000/ne2000.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,6 +43,6 @@
 #include <malloc.h>
 #include <sysinfo.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <ipc/irc.h>
 #include <net/modules.h>
@@ -316,5 +316,5 @@
 		ne2k_cmds[5].addr = ne2k->port + DP_TSR;
 		
-		int rc = ipc_register_irq(ne2k->irq, device->device_id,
+		int rc = register_irq(ne2k->irq, device->device_id,
 		    device->device_id, &ne2k_code);
 		if (rc != EOK)
@@ -323,5 +323,5 @@
 		rc = ne2k_up(ne2k);
 		if (rc != EOK) {
-			ipc_unregister_irq(ne2k->irq, device->device_id);
+			unregister_irq(ne2k->irq, device->device_id);
 			return rc;
 		}
@@ -342,5 +342,5 @@
 		
 		ne2k_down(ne2k);
-		ipc_unregister_irq(ne2k->irq, device->device_id);
+		unregister_irq(ne2k->irq, device->device_id);
 		change_state(device, NETIF_STOPPED);
 	}
@@ -389,13 +389,11 @@
 	
 	if (irc_service) {
-		while (irc_phone < 0) {
-			irc_phone = ipc_connect_me_to_blocking(PHONE_NS, irc_service,
-			    0, 0);
-		}
+		while (irc_phone < 0)
+			irc_phone = service_connect_blocking(irc_service, 0, 0);
 	}
 	
 	async_set_interrupt_received(irq_handler);
 	
-	return ipc_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, NULL, NULL);
+	return async_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, NULL);
 }
 
Index: uspace/srv/loader/arch/abs32le/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/abs32le/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/abs32le/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -3,4 +3,5 @@
  * is the base address and the special interp section.
  */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -54,8 +55,4 @@
 	} :data
 	
-	. = ALIGN(0x1000);
-	
-	_heap = .;
-	
 	/DISCARD/ : {
 		*(*);
Index: uspace/srv/loader/arch/amd64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/amd64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/amd64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -1,2 +1,7 @@
+/*
+ * The difference from _link.ld.in for regular statically-linked apps
+ * is the base address and the special interp section.
+ */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -6,4 +11,5 @@
 	text PT_LOAD FLAGS(5);
 	data PT_LOAD FLAGS(6);
+	debug PT_NOTE;
 }
 
@@ -11,7 +17,7 @@
 	.interp : {
 		*(.interp);
-	} : interp
-
-	/* . = 0x0000700000001000;*/
+	} :interp
+	
+	/* . = 0x0000700000001000; */
 	. = 0x70001000;
 	
@@ -19,4 +25,5 @@
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
@@ -27,4 +34,5 @@
 		*(.data);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -32,4 +40,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -37,16 +46,27 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.bss : {
 		*(COMMON);
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x1000);
-	_heap = .;
+	
+#ifdef CONFIG_LINE_DEBUG
+	.comment 0 : { *(.comment); } :debug
+	.debug_abbrev 0 : { *(.debug_abbrev); } :debug
+	.debug_aranges 0 : { *(.debug_aranges); } :debug
+	.debug_info 0 : { *(.debug_info); } :debug
+	.debug_line 0 : { *(.debug_line); } :debug
+	.debug_loc 0 : { *(.debug_loc); } :debug
+	.debug_pubnames 0 : { *(.debug_pubnames); } :debug
+	.debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
+	.debug_ranges 0 : { *(.debug_ranges); } :debug
+	.debug_str 0 : { *(.debug_str); } :debug
+#endif
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/srv/loader/arch/arm32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/arm32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/arm32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -3,4 +3,5 @@
  * is the base address.
  */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -16,13 +17,14 @@
 		*(.interp);
 	} : interp
-
+	
 	. = 0x70001000;
-
+	
 	.init ALIGN(0x1000): SUBALIGN(0x1000) {
 		*(.init);
-	} : text
+	} :text
+	
 	.text : {
 		*(.text);
-        *(.rodata*);
+		*(.rodata*);
 	} :text
 	
@@ -32,4 +34,5 @@
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -37,4 +40,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -42,18 +46,16 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.bss : {
 		*(.sbss);
 		*(.scommon);
-        *(COMMON);
-        *(.bss);
+		*(COMMON);
+		*(.bss);
 	} :data
-	
-	. = ALIGN(0x1000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/srv/loader/arch/ia32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/ia32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -3,4 +3,5 @@
  * is the base address and the special interp section.
  */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -10,4 +11,5 @@
 	text PT_LOAD FILEHDR PHDRS FLAGS(5);
 	data PT_LOAD FLAGS(6);
+	debug PT_NOTE;
 }
 
@@ -52,7 +54,16 @@
 	} :data
 	
-	. = ALIGN(0x1000);
-	
-	_heap = .;
+#ifdef CONFIG_LINE_DEBUG
+	.comment 0 : { *(.comment); } :debug
+	.debug_abbrev 0 : { *(.debug_abbrev); } :debug
+	.debug_aranges 0 : { *(.debug_aranges); } :debug
+	.debug_info 0 : { *(.debug_info); } :debug
+	.debug_line 0 : { *(.debug_line); } :debug
+	.debug_loc 0 : { *(.debug_loc); } :debug
+	.debug_pubnames 0 : { *(.debug_pubnames); } :debug
+	.debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
+	.debug_ranges 0 : { *(.debug_ranges); } :debug
+	.debug_str 0 : { *(.debug_str); } :debug
+#endif
 	
 	/DISCARD/ : {
Index: uspace/srv/loader/arch/ia64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/ia64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -12,22 +12,24 @@
 		*(.interp);
 	} :interp
-
+	
 	/* On Itanium code sections must be aligned to 16 bytes. */
 	. = ALIGN(0x800000000 + SIZEOF_HEADERS, 16);
-
+	
 	.init : {
 		*(.init);
-	} : text
+	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x4000;
-
+	
 	.got : {
 		_gp = .;
 		*(.got*);
-	} :data	
+	} :data
+	
 	.data : {
 		*(.opd);
@@ -35,4 +37,5 @@
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -40,4 +43,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -45,5 +49,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.bss : {
 		*(.sbss);
@@ -52,10 +58,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
- 
+	
 	/DISCARD/ : {
 		*(*);
-        }
+	}
 }
Index: uspace/srv/loader/arch/mips32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/mips32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/mips32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -3,4 +3,5 @@
  * is the base address.
  */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -16,5 +17,5 @@
 		*(.interp);
 	} :interp
-
+	
 	. = 0x70004000;
 	
@@ -22,19 +23,22 @@
 		*(.init);
 	} :text
+	
 	.text : {
-	        *(.text);
+		*(.text);
 		*(.rodata*);
 	} :text
-
+	
+	. = . + 0x4000;
+	
 	.data : {
 		*(.data);
 		*(.data.rel*);
 	} :data
-
+	
 	.got : {
 		_gp = .;
 		*(.got);
 	} :data
-
+	
 	.tdata : {
 		_tdata_start = .;
@@ -42,4 +46,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -47,18 +52,17 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
-
+	
 	.sbss : {
 		*(.scommon);
 		*(.sbss);
-	}	
+	}
+	
 	.bss : {
 		*(.bss);
 		*(COMMON);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
-
+	
 	/DISCARD/ : {
 		*(*);
Index: uspace/srv/loader/arch/ppc32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ppc32/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/ppc32/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -3,4 +3,5 @@
  * is the base address.
  */
+
 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
 ENTRY(__entry)
@@ -16,10 +17,11 @@
 		*(.interp);
 	} :interp
-
+	
 	. = 0x70001000;
-
+	
 	.init ALIGN(0x1000) : SUBALIGN(0x1000) {
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
@@ -31,4 +33,5 @@
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -36,4 +39,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -41,5 +45,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.bss : {
 		*(.sbss);
@@ -47,11 +53,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x1000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/srv/loader/arch/sparc64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/sparc64/_link.ld.in	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/arch/sparc64/_link.ld.in	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -12,25 +12,28 @@
 		*(.interp);
 	} :interp
-
+	
 	. = 0x70004000 + SIZEOF_HEADERS;
-
+	
 	.init : {
 		*(.init);
 	} :text
+	
 	.text : {
 		*(.text);
 		*(.rodata*);
 	} :text
-
+	
 	. = . + 0x4000;
-
+	
 	.got : {
 		 _gp = .;
 		 *(.got*);
 	} :data
+	
 	.data : {
 		*(.data);
 		*(.sdata);
 	} :data
+	
 	.tdata : {
 		_tdata_start = .;
@@ -38,4 +41,5 @@
 		_tdata_end = .;
 	} :data
+	
 	.tbss : {
 		_tbss_start = .;
@@ -43,5 +47,7 @@
 		_tbss_end = .;
 	} :data
+	
 	_tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
+	
 	.bss : {
 		*(.sbss);
@@ -49,11 +55,7 @@
 		*(.bss);
 	} :data
-
-	. = ALIGN(0x4000);
-	_heap = .;
 	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: uspace/srv/loader/elf_load.c
===================================================================
--- uspace/srv/loader/elf_load.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/elf_load.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -109,5 +109,5 @@
 	int fd;
 	int rc;
-
+	
 	fd = open(file_name, O_RDONLY);
 	if (fd < 0) {
@@ -300,4 +300,5 @@
 	case PT_NULL:
 	case PT_PHDR:
+	case PT_NOTE:
 		break;
 	case PT_LOAD:
@@ -310,5 +311,4 @@
 	case PT_DYNAMIC:
 	case PT_SHLIB:
-	case PT_NOTE:
 	case PT_LOPROC:
 	case PT_HIPROC:
@@ -344,5 +344,5 @@
 	seg_ptr = (void *) seg_addr;
 
-	DPRINTF("Load segment at addr %p, size 0x%x\n", seg_addr,
+	DPRINTF("Load segment at addr %p, size 0x%x\n", (void *) seg_addr,
 		entry->p_memsz);
 
@@ -372,6 +372,7 @@
 	mem_sz = entry->p_memsz + (entry->p_vaddr - base);
 
-	DPRINTF("Map to seg_addr=%p-%p.\n", seg_addr,
-	entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
+	DPRINTF("Map to seg_addr=%p-%p.\n", (void *) seg_addr,
+	    (void *) (entry->p_vaddr + bias +
+	    ALIGN_UP(entry->p_memsz, PAGE_SIZE)));
 
 	/*
@@ -386,6 +387,6 @@
 	}
 
-	DPRINTF("as_area_create(%p, 0x%x, %d) -> 0x%lx\n",
-		base + bias, mem_sz, flags, (uintptr_t)a);
+	DPRINTF("as_area_create(%p, %#zx, %d) -> %p\n",
+	    (void *) (base + bias), mem_sz, flags, (void *) a);
 
 	/*
@@ -464,5 +465,5 @@
 		    (void *)((uint8_t *)entry->sh_addr + elf->bias);
 		DPRINTF("Dynamic section found at %p.\n",
-			(uintptr_t)elf->info->dynamic);
+		    (void *) elf->info->dynamic);
 		break;
 	default:
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/loader/main.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -50,5 +50,4 @@
 #include <fcntl.h>
 #include <sys/types.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/loader.h>
@@ -95,5 +94,5 @@
 
 /** Used to limit number of connections to one. */
-static bool connected;
+static bool connected = false;
 
 static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request)
@@ -106,6 +105,6 @@
 	
 	if (!async_data_read_receive(&callid, &len)) {
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -115,5 +114,5 @@
 	
 	async_data_read_finalize(callid, &task_id, len);
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -135,5 +134,5 @@
 	}
 	
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -155,5 +154,5 @@
 	}
 	
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -188,5 +187,5 @@
 		if (_argv == NULL) {
 			free(buf);
-			ipc_answer_0(rid, ENOMEM);
+			async_answer_0(rid, ENOMEM);
 			return;
 		}
@@ -220,5 +219,5 @@
 	}
 	
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -244,5 +243,5 @@
 		if (_filv == NULL) {
 			free(buf);
-			ipc_answer_0(rid, ENOMEM);
+			async_answer_0(rid, ENOMEM);
 			return;
 		}
@@ -271,5 +270,5 @@
 	}
 	
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -287,5 +286,5 @@
 	if (rc != EE_OK) {
 		DPRINTF("Failed to load executable '%s'.\n", pathname);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return 1;
 	}
@@ -304,5 +303,5 @@
 		/* Statically linked program */
 		is_dyn_linked = false;
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		return 0;
 	}
@@ -312,10 +311,10 @@
 		DPRINTF("Failed to load interpreter '%s.'\n",
 		    prog_info.interp);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return 1;
 	}
 	
 	is_dyn_linked = true;
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 	
 	return 0;
@@ -343,9 +342,9 @@
 		DPRINTF("Entry point: %p\n", interp_info.entry);
 		
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		elf_run(&interp_info, &pcb);
 	} else {
 		/* Statically linked program */
-		ipc_answer_0(rid, EOK);
+		async_answer_0(rid, EOK);
 		elf_run(&prog_info, &pcb);
 	}
@@ -367,5 +366,5 @@
 	/* Already have a connection? */
 	if (connected) {
-		ipc_answer_0(iid, ELIMIT);
+		async_answer_0(iid, ELIMIT);
 		return;
 	}
@@ -374,5 +373,5 @@
 	
 	/* Accept the connection */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	/* Ignore parameters, the connection is already open */
@@ -414,5 +413,5 @@
 			DPRINTF("Responding EINVAL to method %d.\n",
 			    IPC_GET_IMETHOD(call));
-			ipc_answer_0(callid, EINVAL);
+			async_answer_0(callid, EINVAL);
 		}
 	}
@@ -423,22 +422,17 @@
 int main(int argc, char *argv[])
 {
-	task_id_t id;
-	int rc;
-
-	connected = false;
-
+	/* Set a handler of incomming connections. */
+	async_set_client_connection(ldr_connection);
+	
 	/* Introduce this task to the NS (give it our task ID). */
-	id = task_get_id();
-	rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));
+	task_id_t id = task_get_id();
+	int rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));
 	if (rc != EOK)
 		return -1;
-
-	/* Set a handler of incomming connections. */
-	async_set_client_connection(ldr_connection);
 	
 	/* Register at naming service. */
-	if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, NULL, NULL) != 0)
+	if (service_register(SERVICE_LOAD) != EOK)
 		return -2;
-
+	
 	async_manager();
 	
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/il/arp/arp.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -45,5 +45,4 @@
 #include <task.h>
 #include <adt/measured_strings.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -428,5 +427,5 @@
 		case NET_IL_DEVICE_STATE:
 			/* Do nothing - keep the cache */
-			ipc_answer_0(iid, (sysarg_t) EOK);
+			async_answer_0(iid, (sysarg_t) EOK);
 			break;
 		
@@ -448,5 +447,5 @@
 				fibril_mutex_unlock(&arp_globals.lock);
 			}
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
@@ -454,9 +453,9 @@
 			rc = arp_mtu_changed_message(IPC_GET_DEVICE(*icall),
 			    IPC_GET_MTU(*icall));
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/il/arp/arp.h
===================================================================
--- uspace/srv/net/il/arp/arp.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/il/arp/arp.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,8 +39,5 @@
 
 #include <fibril_synch.h>
-
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <net/device.h>
 #include <net/packet.h>
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/il/ip/ip.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <str.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -1596,5 +1595,5 @@
 			rc = ip_device_state_message(IPC_GET_DEVICE(*icall),
 			    IPC_GET_STATE(*icall));
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
@@ -1610,5 +1609,5 @@
 			}
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
@@ -1616,9 +1615,9 @@
 			rc = ip_mtu_changed_message(IPC_GET_DEVICE(*icall),
 			    IPC_GET_MTU(*icall));
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/il/ip/ip.h
===================================================================
--- uspace/srv/net/il/ip/ip.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/il/ip/ip.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,7 +39,5 @@
 
 #include <fibril_synch.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
-
 #include <net/device.h>
 #include <net/inet.h>
Index: uspace/srv/net/net/net.c
===================================================================
--- uspace/srv/net/net/net.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/net/net.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -47,5 +47,4 @@
 #include <str_error.h>
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -337,5 +336,5 @@
 		goto out;
 	
-	rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL, NULL);
+	rc = async_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL);
 	if (rc != EOK)
 		goto out;
@@ -686,5 +685,5 @@
 	 *  - Answer the first IPC_M_CONNECT_ME_TO call.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (true) {
Index: uspace/srv/net/net/net.h
===================================================================
--- uspace/srv/net/net/net.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/net/net.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -38,6 +38,4 @@
 #ifndef NET_NET_H_
 #define NET_NET_H_
-
-#include <ipc/ipc.h>
 
 #include <net/device.h>
Index: uspace/srv/net/net/net_standalone.c
===================================================================
--- uspace/srv/net/net/net_standalone.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/net/net_standalone.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <adt/measured_strings.h>
 #include <adt/module_map.h>
-#include <ipc/ipc.h>
 #include <ipc/net.h>
 #include <errno.h>
Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/netif/lo/lo.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -39,9 +39,6 @@
 #include <stdio.h>
 #include <str.h>
-
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/nil.h>
-
 #include <net/modules.h>
 #include <adt/measured_strings.h>
@@ -167,5 +164,5 @@
 int netif_initialize(void)
 {
-	return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, NULL, NULL);
+	return async_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, NULL);
 }
 
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/nil/eth/eth.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,10 +43,7 @@
 #include <str.h>
 #include <errno.h>
-
-#include <ipc/ipc.h>
 #include <ipc/nil.h>
 #include <ipc/net.h>
 #include <ipc/services.h>
-
 #include <net/modules.h>
 #include <net_checksum.h>
@@ -242,5 +239,5 @@
 			nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall),
 			    IPC_GET_STATE(*icall));
-			ipc_answer_0(iid, EOK);
+			async_answer_0(iid, EOK);
 			break;
 		case NET_NIL_RECEIVED:
@@ -251,8 +248,8 @@
 				    IPC_GET_DEVICE(*icall), packet, 0);
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <str.h>
-#include <ipc/ipc.h>
 #include <ipc/nil.h>
 #include <ipc/net.h>
@@ -112,5 +111,5 @@
 			rc = nil_device_state_msg_local(0,
 			    IPC_GET_DEVICE(*icall), IPC_GET_STATE(*icall));
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
@@ -122,9 +121,9 @@
 				    IPC_GET_DEVICE(*icall), packet, 0);
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -41,5 +41,4 @@
 #include <stdint.h>
 #include <str.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -628,5 +627,5 @@
 			}
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		case IPC_M_PHONE_HUNGUP:
@@ -634,5 +633,5 @@
 			continue;
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/tl/tcp/tcp.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/tl/tcp/tcp.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -44,5 +44,4 @@
 #include <errno.h>
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -1506,5 +1505,5 @@
 
 	/* Release the application phone */
-	ipc_hangup(app_phone);
+	async_hangup(app_phone);
 
 	printf("release\n");
@@ -2454,8 +2453,8 @@
 				    SERVICE_TCP, IPC_GET_ERROR(*icall));
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/net/tl/udp/udp.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -40,5 +40,4 @@
 #include <malloc.h>
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <ipc/net.h>
@@ -354,8 +353,8 @@
 				    SERVICE_UDP, IPC_GET_ERROR(*icall));
 			
-			ipc_answer_0(iid, (sysarg_t) rc);
+			async_answer_0(iid, (sysarg_t) rc);
 			break;
 		default:
-			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
+			async_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
@@ -868,5 +867,5 @@
 
 	/* Release the application phone */
-	ipc_hangup(app_phone);
+	async_hangup(app_phone);
 
 	/* Release all local sockets */
Index: uspace/srv/ns/clonable.c
===================================================================
--- uspace/srv/ns/clonable.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/clonable.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -92,5 +92,5 @@
 	
 	ipc_forward_fast(csr->callid, phone, IPC_GET_ARG2(csr->call),
-		IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE);
+	    IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE);
 	
 	free(csr);
@@ -127,4 +127,5 @@
 	}
 	
+	link_initialize(&csr->link);
 	csr->service = service;
 	csr->call = *call;
Index: uspace/srv/ns/clonable.h
===================================================================
--- uspace/srv/ns/clonable.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/clonable.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,14 +34,13 @@
 #define NS_CLONABLE_H__
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
+#include <sys/types.h>
 #include <bool.h>
 
 extern int clonable_init(void);
 
-extern bool service_clonable(int service);
-extern void register_clonable(sysarg_t service, sysarg_t phone,
-    ipc_call_t *call, ipc_callid_t callid);
-extern void connect_to_clonable(sysarg_t service, ipc_call_t *call,
-    ipc_callid_t callid);
+extern bool service_clonable(int);
+extern void register_clonable(sysarg_t, sysarg_t, ipc_call_t *, ipc_callid_t);
+extern void connect_to_clonable(sysarg_t, ipc_call_t *, ipc_callid_t);
 
 #endif
Index: uspace/srv/ns/ns.c
===================================================================
--- uspace/srv/ns/ns.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/ns.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,75 +37,12 @@
 
 #include <ipc/ipc.h>
-#include <ipc/services.h>
 #include <ipc/ns.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
-#include <as.h>
-#include <ddi.h>
-#include <event.h>
 #include <macros.h>
-#include <sysinfo.h>
 #include "ns.h"
 #include "service.h"
 #include "clonable.h"
 #include "task.h"
-
-static void *clockaddr = NULL;
-static void *klogaddr = NULL;
-
-static void get_as_area(ipc_callid_t callid, ipc_call_t *call, void *faddr,
-    size_t pages, void **addr)
-{
-	if ((faddr == NULL) || (pages == 0)) {
-		ipc_answer_0(callid, ENOENT);
-		return;
-	}
-	
-	if (*addr == NULL) {
-		*addr = as_get_mappable_page(pages * PAGE_SIZE);
-		
-		if (*addr == NULL) {
-			ipc_answer_0(callid, ENOENT);
-			return;
-		}
-		
-		if (physmem_map(faddr, *addr, pages,
-		    AS_AREA_READ | AS_AREA_CACHEABLE) != 0) {
-			ipc_answer_0(callid, ENOENT);
-			return;
-		}
-	}
-	
-	ipc_answer_2(callid, EOK, (sysarg_t) *addr, AS_AREA_READ);
-}
-
-static void setup_clock_area(ipc_callid_t callid, ipc_call_t *call, void **addr)
-{
-	uintptr_t faddr;
-	int err = sysinfo_get_value("clock.faddr", &faddr);
-	
-	if (err != EOK)
-		ipc_answer_0(callid, err);
-	
-	get_as_area(callid, call, (void *) faddr, 1, addr);
-}
-
-static void setup_klog_area(ipc_callid_t callid, ipc_call_t *call, void **addr)
-{
-	uintptr_t faddr;
-	int err = sysinfo_get_value("klog.faddr", &faddr);
-	
-	if (err != EOK)
-		ipc_answer_0(callid, err);
-	
-	size_t pages;
-	err = sysinfo_get_value("klog.pages", &pages);
-	
-	if (err != EOK)
-		ipc_answer_0(callid, err);
-	
-	get_as_area(callid, call, (void *) faddr, pages, addr);
-}
 
 int main(int argc, char **argv)
@@ -138,16 +75,4 @@
 		
 		switch (IPC_GET_IMETHOD(call)) {
-		case IPC_M_SHARE_IN:
-			switch (IPC_GET_ARG3(call)) {
-			case SERVICE_MEM_REALTIME:
-				setup_clock_area(callid, &call, &clockaddr);
-				break;
-			case SERVICE_MEM_KLOG:
-				setup_klog_area(callid, &call, &klogaddr);
-				break;
-			default:
-				ipc_answer_0(callid, ENOENT);
-			}
-			continue;
 		case IPC_M_PHONE_HUNGUP:
 			retval = ns_task_disconnect(&call);
Index: uspace/srv/ns/service.c
===================================================================
--- uspace/srv/ns/service.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/service.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,5 +43,5 @@
 typedef struct {
 	link_t link;
-	sysarg_t service;        /**< Number of the service. */
+	sysarg_t service;        /**< Service ID. */
 	sysarg_t phone;          /**< Phone registered with the service. */
 	sysarg_t in_phone_hash;  /**< Incoming phone hash. */
@@ -56,8 +56,8 @@
  *
  */
-static hash_index_t service_hash(unsigned long *key)
+static hash_index_t service_hash(unsigned long key[])
 {
 	assert(key);
-	return (*key % SERVICE_HASH_TABLE_CHAINS);
+	return (key[0] % SERVICE_HASH_TABLE_CHAINS);
 }
 
@@ -86,5 +86,5 @@
 	
 	if (keys == 2)
-		return (key[1] == hs->in_phone_hash);
+		return ((key[0] == hs->service) && (key[1] == hs->in_phone_hash));
 	else
 		return (key[0] == hs->service);
@@ -195,5 +195,5 @@
 	hash_table_insert(&service_hash_table, keys, &hs->link);
 	
-	return 0;
+	return EOK;
 }
 
@@ -227,4 +227,5 @@
 			}
 			
+			link_initialize(&pr->link);
 			pr->service = service;
 			pr->callid = callid;
Index: uspace/srv/ns/service.h
===================================================================
--- uspace/srv/ns/service.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/service.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,12 +34,12 @@
 #define NS_SERVICE_H__
 
-#include <ipc/ipc.h>
+#include <sys/types.h>
+#include <ipc/common.h>
 
 extern int service_init(void);
 extern void process_pending_conn(void);
 
-extern int register_service(sysarg_t service, sysarg_t phone, ipc_call_t *call);
-extern void connect_to_service(sysarg_t service, ipc_call_t *call,
-     ipc_callid_t callid);
+extern int register_service(sysarg_t, sysarg_t, ipc_call_t *);
+extern void connect_to_service(sysarg_t, ipc_call_t *, ipc_callid_t);
 
 #endif
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/task.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -43,7 +43,5 @@
 
 #define TASK_HASH_TABLE_CHAINS  256
-#define P2I_HASH_TABLE_CHAINS  256
-
-static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id);
+#define P2I_HASH_TABLE_CHAINS   256
 
 /* TODO:
@@ -57,8 +55,9 @@
 typedef struct {
 	link_t link;
-	task_id_t id;	/**< Task ID. */
-	bool finished;	/**< Task is done. */
-	bool have_rval;	/**< Task returned a value. */
-	int retval;	/**< The return value. */
+	
+	task_id_t id;    /**< Task ID. */
+	bool finished;   /**< Task is done. */
+	bool have_rval;  /**< Task returned a value. */
+	int retval;      /**< The return value. */
 } hashed_task_t;
 
@@ -71,8 +70,8 @@
  *
  */
-static hash_index_t task_hash(unsigned long *key)
+static hash_index_t task_hash(unsigned long key[])
 {
 	assert(key);
-	return (LOWER32(*key) % TASK_HASH_TABLE_CHAINS);
+	return (LOWER32(key[0]) % TASK_HASH_TABLE_CHAINS);
 }
 
@@ -124,6 +123,6 @@
 typedef struct {
 	link_t link;
-	sysarg_t phash;    /**< Task ID. */
-	task_id_t id;    /**< Task ID. */
+	sysarg_t in_phone_hash;  /**< Incoming phone hash. */
+	task_id_t id;            /**< Task ID. */
 } p2i_entry_t;
 
@@ -131,11 +130,12 @@
  *
  * @param key Array of keys.
+ *
  * @return Hash index corresponding to key[0].
  *
  */
-static hash_index_t p2i_hash(unsigned long *key)
+static hash_index_t p2i_hash(unsigned long key[])
 {
 	assert(key);
-	return (*key % TASK_HASH_TABLE_CHAINS);
+	return (key[0] % TASK_HASH_TABLE_CHAINS);
 }
 
@@ -154,8 +154,8 @@
 	assert(keys == 1);
 	assert(item);
-
-	p2i_entry_t *e = hash_table_get_instance(item, p2i_entry_t, link);
-
-	return (key[0] == e->phash);
+	
+	p2i_entry_t *entry = hash_table_get_instance(item, p2i_entry_t, link);
+	
+	return (key[0] == entry->in_phone_hash);
 }
 
@@ -197,5 +197,5 @@
 		return ENOMEM;
 	}
-
+	
 	if (!hash_table_create(&phone_to_id, P2I_HASH_TABLE_CHAINS,
 	    1, &p2i_ops)) {
@@ -205,5 +205,4 @@
 	
 	list_initialize(&pending_wait);
-	
 	return EOK;
 }
@@ -238,5 +237,5 @@
 			    ht->retval);
 		}
-
+		
 		hash_table_remove(&task_hash_table, keys, 2);
 		list_remove(cur);
@@ -250,14 +249,14 @@
 	sysarg_t retval;
 	task_exit_t texit;
-
+	
 	unsigned long keys[2] = {
 		LOWER32(id),
 		UPPER32(id)
 	};
-
+	
 	link_t *link = hash_table_find(&task_hash_table, keys);
 	hashed_task_t *ht = (link != NULL) ?
 	    hash_table_get_instance(link, hashed_task_t, link) : NULL;
-
+	
 	if (ht == NULL) {
 		/* No such task exists. */
@@ -265,5 +264,5 @@
 		return;
 	}
-
+	
 	if (!ht->finished) {
 		/* Add to pending list */
@@ -275,4 +274,5 @@
 		}
 		
+		link_initialize(&pr->link);
 		pr->id = id;
 		pr->callid = callid;
@@ -293,38 +293,37 @@
 int ns_task_id_intro(ipc_call_t *call)
 {
-	task_id_t id;
 	unsigned long keys[2];
-	link_t *link;
-	p2i_entry_t *e;
-	hashed_task_t *ht;
-
-	id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
-
+	
+	task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
 	keys[0] = call->in_phone_hash;
-
-	link = hash_table_find(&phone_to_id, keys);
+	
+	link_t *link = hash_table_find(&phone_to_id, keys);
 	if (link != NULL)
 		return EEXISTS;
-
-	e = (p2i_entry_t *) malloc(sizeof(p2i_entry_t));
-	if (e == NULL)
+	
+	p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t));
+	if (entry == NULL)
 		return ENOMEM;
-
-	ht = (hashed_task_t *) malloc(sizeof(hashed_task_t));
+	
+	hashed_task_t *ht = (hashed_task_t *) malloc(sizeof(hashed_task_t));
 	if (ht == NULL)
 		return ENOMEM;
-
-	/* Insert to phone-to-id map. */
-
-	link_initialize(&e->link);
-	e->phash = call->in_phone_hash;
-	e->id = id;
-	hash_table_insert(&phone_to_id, keys, &e->link);
-
-	/* Insert to main table. */
-
+	
+	/*
+	 * Insert into the phone-to-id map.
+	 */
+	
+	link_initialize(&entry->link);
+	entry->in_phone_hash = call->in_phone_hash;
+	entry->id = id;
+	hash_table_insert(&phone_to_id, keys, &entry->link);
+	
+	/*
+	 * Insert into the main table.
+	 */
+	
 	keys[0] = LOWER32(id);
 	keys[1] = UPPER32(id);
-
+	
 	link_initialize(&ht->link);
 	ht->id = id;
@@ -333,20 +332,33 @@
 	ht->retval = -1;
 	hash_table_insert(&task_hash_table, keys, &ht->link);
-
+	
 	return EOK;
 }
 
+static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id)
+{
+	unsigned long keys[1] = {phone_hash};
+	
+	link_t *link = hash_table_find(&phone_to_id, keys);
+	if (link == NULL)
+		return ENOENT;
+	
+	p2i_entry_t *entry = hash_table_get_instance(link, p2i_entry_t, link);
+	*id = entry->id;
+	
+	return EOK;
+}
+
 int ns_task_retval(ipc_call_t *call)
 {
 	task_id_t id;
-	unsigned long keys[2];
-	int rc;
-
-	rc = get_id_by_phone(call->in_phone_hash, &id);
+	int rc = get_id_by_phone(call->in_phone_hash, &id);
 	if (rc != EOK)
 		return rc;
-
-	keys[0] = LOWER32(id);
-	keys[1] = UPPER32(id);
+	
+	unsigned long keys[2] = {
+		LOWER32(id),
+		UPPER32(id)
+	};
 	
 	link_t *link = hash_table_find(&task_hash_table, keys);
@@ -354,11 +366,11 @@
 	    hash_table_get_instance(link, hashed_task_t, link) : NULL;
 	
-	if ((ht == NULL) || ht->finished)
+	if ((ht == NULL) || (ht->finished))
 		return EINVAL;
-
+	
 	ht->finished = true;
 	ht->have_rval = true;
 	ht->retval = IPC_GET_ARG1(*call);
-
+	
 	return EOK;
 }
@@ -367,19 +379,18 @@
 {
 	unsigned long keys[2];
+	
 	task_id_t id;
-	int rc;
-
-	rc = get_id_by_phone(call->in_phone_hash, &id);
+	int rc = get_id_by_phone(call->in_phone_hash, &id);
 	if (rc != EOK)
 		return rc;
-
+	
 	/* Delete from phone-to-id map. */
 	keys[0] = call->in_phone_hash;
 	hash_table_remove(&phone_to_id, keys, 1);
-
+	
 	/* Mark task as finished. */
 	keys[0] = LOWER32(id);
 	keys[1] = UPPER32(id);
-
+	
 	link_t *link = hash_table_find(&task_hash_table, keys);
 	hashed_task_t *ht =
@@ -387,24 +398,7 @@
 	if (ht == NULL)
 		return EOK;
-
+	
 	ht->finished = true;
-
-	return EOK;
-}
-
-static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id)
-{
-	unsigned long keys[1];
-	link_t *link;
-	p2i_entry_t *e;
-
-	keys[0] = phone_hash;
-	link = hash_table_find(&phone_to_id, keys);
-	if (link == NULL)
-		return ENOENT;
-
-	e = hash_table_get_instance(link, p2i_entry_t, link);
-	*id = e->id;
-
+	
 	return EOK;
 }
Index: uspace/srv/ns/task.h
===================================================================
--- uspace/srv/ns/task.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/ns/task.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -34,14 +34,15 @@
 #define NS_TASK_H__
 
-#include <ipc/ipc.h>
+#include <ipc/common.h>
+#include <task.h>
 
 extern int task_init(void);
 extern void process_pending_wait(void);
 
-extern void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid);
+extern void wait_for_task(task_id_t, ipc_call_t *, ipc_callid_t);
 
-extern int ns_task_id_intro(ipc_call_t *call);
-extern int ns_task_disconnect(ipc_call_t *call);
-extern int ns_task_retval(ipc_call_t *call);
+extern int ns_task_id_intro(ipc_call_t *);
+extern int ns_task_disconnect(ipc_call_t *);
+extern int ns_task_retval(ipc_call_t *);
 
 
Index: uspace/srv/taskmon/taskmon.c
===================================================================
--- uspace/srv/taskmon/taskmon.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/taskmon/taskmon.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
 
 #include <stdio.h>
-#include <ipc/ipc.h>
 #include <async.h>
 #include <ipc/services.h>
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/vfs/vfs.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,6 +36,6 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/ns.h>
 #include <async.h>
 #include <errno.h>
@@ -47,5 +47,5 @@
 #include "vfs.h"
 
-#define NAME "vfs"
+#define NAME  "vfs"
 
 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall)
@@ -57,5 +57,5 @@
 	 * This call needs to be answered.
 	 */
-	ipc_answer_0(iid, EOK);
+	async_answer_0(iid, EOK);
 	
 	while (keep_on_going) {
@@ -119,5 +119,5 @@
 			vfs_dup(callid, &call);
 		default:
-			ipc_answer_0(callid, ENOTSUP);
+			async_answer_0(callid, ENOTSUP);
 			break;
 		}
@@ -172,5 +172,8 @@
 	 * Register at the naming service.
 	 */
-	ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, NULL, NULL);
+	if (service_register(SERVICE_VFS) != EOK) {
+		printf("%s: Cannot register VFS service\n", NAME);
+		return EINVAL;
+	}
 	
 	/*
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/vfs/vfs.h	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -35,5 +35,4 @@
 
 #include <async.h>
-#include <ipc/ipc.h>
 #include <adt/list.h>
 #include <fibril_synch.h>
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/vfs/vfs_lookup.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 
 #include "vfs.h"
-#include <ipc/ipc.h>
 #include <macros.h>
 #include <async.h>
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/vfs/vfs_ops.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -37,5 +37,4 @@
 
 #include "vfs.h"
-#include <ipc/ipc.h>
 #include <macros.h>
 #include <stdint.h>
@@ -91,5 +90,5 @@
 			/* Trying to mount root FS over root FS */
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, EBUSY);
+			async_answer_0(rid, EBUSY);
 			return;
 		}
@@ -99,5 +98,5 @@
 			/* The lookup failed for some reason. */
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -106,5 +105,5 @@
 		if (!mp_node) {
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, ENOMEM);
+			async_answer_0(rid, ENOMEM);
 			return;
 		}
@@ -134,5 +133,5 @@
 				vfs_release_phone(fs_handle, phone);
 				fibril_rwlock_write_unlock(&namespace_rwlock);
-				ipc_answer_0(rid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -142,5 +141,5 @@
 			if (rc != EOK) {
 				fibril_rwlock_write_unlock(&namespace_rwlock);
-				ipc_answer_0(rid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -165,5 +164,5 @@
 			
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		} else {
@@ -173,5 +172,5 @@
 			 */
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, ENOENT);
+			async_answer_0(rid, ENOENT);
 			return;
 		}
@@ -202,5 +201,5 @@
 		if (mp_node)
 			vfs_node_put(mp_node);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		fibril_rwlock_write_unlock(&namespace_rwlock);
 		return;
@@ -218,5 +217,5 @@
 			vfs_node_put(mp_node);
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -245,5 +244,5 @@
 	}
 
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 	fibril_rwlock_write_unlock(&namespace_rwlock);
 }
@@ -275,5 +274,5 @@
 	    0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -285,5 +284,5 @@
 	if (rc != EOK) {
 		free(mp);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -299,5 +298,5 @@
 		free(mp);
 		free(opts);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -310,6 +309,6 @@
 	ipc_callid_t callid = async_get_call(&data);
 	if (IPC_GET_IMETHOD(data) != IPC_M_PING) {
-		ipc_answer_0(callid, ENOTSUP);
-		ipc_answer_0(rid, ENOTSUP);
+		async_answer_0(callid, ENOTSUP);
+		async_answer_0(rid, ENOTSUP);
 		free(mp);
 		free(opts);
@@ -333,6 +332,6 @@
 		
 		fibril_mutex_unlock(&fs_head_lock);
-		ipc_answer_0(callid, ENOENT);
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(callid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		free(mp);
 		free(fs_name);
@@ -343,5 +342,5 @@
 	
 	/* Acknowledge that we know fs_name. */
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 	
 	/* Do the mount */
@@ -367,5 +366,5 @@
 	    0, NULL);
 	if (rc != EOK)
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 
 	/*
@@ -386,5 +385,5 @@
 		fibril_rwlock_write_unlock(&namespace_rwlock);
 		free(mp);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -393,5 +392,5 @@
 		fibril_rwlock_write_unlock(&namespace_rwlock);
 		free(mp);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -409,5 +408,5 @@
 		vfs_node_put(mr_node);
 		free(mp);
-		ipc_answer_0(rid, EBUSY);
+		async_answer_0(rid, EBUSY);
 		return;
 	}
@@ -430,5 +429,5 @@
 			fibril_rwlock_write_unlock(&namespace_rwlock);
 			vfs_node_put(mr_node);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -449,5 +448,5 @@
 			fibril_rwlock_write_unlock(&namespace_rwlock);
 			vfs_node_put(mr_node);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -456,5 +455,5 @@
 			fibril_rwlock_write_unlock(&namespace_rwlock);
 			vfs_node_put(mr_node);
-			ipc_answer_0(rid, ENOMEM);
+			async_answer_0(rid, ENOMEM);
 			return;
 		}
@@ -468,5 +467,5 @@
 			vfs_node_put(mp_node);
 			vfs_node_put(mr_node);
-			ipc_answer_0(rid, rc);
+			async_answer_0(rid, rc);
 			return;
 		}
@@ -486,5 +485,5 @@
 
 	fibril_rwlock_write_unlock(&namespace_rwlock);
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -514,5 +513,5 @@
 	    ((lflag & (L_FILE | L_DIRECTORY)) == (L_FILE | L_DIRECTORY)) ||
 	    (lflag & (L_OPEN | L_ROOT | L_MP))) {
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -526,5 +525,5 @@
 	int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -548,5 +547,5 @@
 		else
 			fibril_rwlock_read_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(path);
 		return;
@@ -571,5 +570,5 @@
 				fibril_rwlock_write_unlock(&node->contents_rwlock);
 				vfs_node_put(node);
-				ipc_answer_0(rid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -586,5 +585,5 @@
 	if (fd < 0) {
 		vfs_node_put(node);
-		ipc_answer_0(rid, fd);
+		async_answer_0(rid, fd);
 		return;
 	}
@@ -607,5 +606,5 @@
 	
 	/* Success! Return the new file descriptor to the client. */
-	ipc_answer_1(rid, EOK, fd);
+	async_answer_1(rid, EOK, fd);
 }
 
@@ -629,5 +628,5 @@
 	if (rc != EOK) {
 		fibril_rwlock_read_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -645,5 +644,5 @@
 				fibril_rwlock_write_unlock(&node->contents_rwlock);
 				vfs_node_put(node);
-				ipc_answer_0(rid, rc);
+				async_answer_0(rid, rc);
 				return;
 			}
@@ -660,5 +659,5 @@
 	if (fd < 0) {
 		vfs_node_put(node);
-		ipc_answer_0(rid, fd);
+		async_answer_0(rid, fd);
 		return;
 	}
@@ -680,5 +679,5 @@
 	
 	/* Success! Return the new file descriptor to the client. */
-	ipc_answer_1(rid, EOK, fd);
+	async_answer_1(rid, EOK, fd);
 }
 
@@ -690,5 +689,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -715,5 +714,5 @@
 
 	vfs_file_put(file);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -760,5 +759,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -766,9 +765,9 @@
 	int ret = vfs_close_internal(file);
 	if (ret != EOK)
-		ipc_answer_0(rid, ret);
+		async_answer_0(rid, ret);
 	
 	vfs_file_put(file);
 	ret = vfs_fd_free(fd);
-	ipc_answer_0(rid, ret);
+	async_answer_0(rid, ret);
 }
 
@@ -792,5 +791,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -875,5 +874,5 @@
 	 * return to the client.
 	 */
-	ipc_answer_1(rid, rc, bytes);
+	async_answer_1(rid, rc, bytes);
 }
 
@@ -898,5 +897,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -911,5 +910,5 @@
 			fibril_mutex_unlock(&file->lock);
 			vfs_file_put(file);
-			ipc_answer_1(rid, EOK, off);
+			async_answer_1(rid, EOK, off);
 			return;
 		}
@@ -919,5 +918,5 @@
 			fibril_mutex_unlock(&file->lock);
 			vfs_file_put(file);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			return;
 		}
@@ -926,5 +925,5 @@
 			fibril_mutex_unlock(&file->lock);
 			vfs_file_put(file);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			return;
 		}
@@ -935,5 +934,5 @@
 		fibril_mutex_unlock(&file->lock);
 		vfs_file_put(file);
-		ipc_answer_2(rid, EOK, LOWER32(newoff),
+		async_answer_2(rid, EOK, LOWER32(newoff),
 		    UPPER32(newoff));
 		return;
@@ -946,5 +945,5 @@
 			fibril_mutex_unlock(&file->lock);
 			vfs_file_put(file);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			return;
 		}
@@ -954,5 +953,5 @@
 			fibril_mutex_unlock(&file->lock);
 			vfs_file_put(file);
-			ipc_answer_0(rid, EOVERFLOW);
+			async_answer_0(rid, EOVERFLOW);
 			return;
 		}
@@ -964,5 +963,5 @@
 		fibril_mutex_unlock(&file->lock);
 		vfs_file_put(file);
-		ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
+		async_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
 		return;
 	}
@@ -970,5 +969,5 @@
 	fibril_mutex_unlock(&file->lock);
 	vfs_file_put(file);
-	ipc_answer_0(rid, EINVAL);
+	async_answer_0(rid, EINVAL);
 }
 
@@ -995,5 +994,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1009,5 +1008,5 @@
 	fibril_mutex_unlock(&file->lock);
 	vfs_file_put(file);
-	ipc_answer_0(rid, (sysarg_t)rc);
+	async_answer_0(rid, (sysarg_t)rc);
 }
 
@@ -1019,5 +1018,5 @@
 	vfs_file_t *file = vfs_file_get(fd);
 	if (!file) {
-		ipc_answer_0(rid, ENOENT);
+		async_answer_0(rid, ENOENT);
 		return;
 	}
@@ -1026,6 +1025,6 @@
 	if (!async_data_read_receive(&callid, NULL)) {
 		vfs_file_put(file);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -1038,5 +1037,5 @@
 	msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle,
 	    file->node->index, true, NULL);
-	ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+	async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 	async_wait_for(msg, &rc);
 	vfs_release_phone(file->node->fs_handle, fs_phone);
@@ -1044,5 +1043,5 @@
 	fibril_mutex_unlock(&file->lock);
 	vfs_file_put(file);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -1052,5 +1051,5 @@
 	int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1059,6 +1058,6 @@
 	if (!async_data_read_receive(&callid, NULL)) {
 		free(path);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -1070,6 +1069,6 @@
 	if (rc != EOK) {
 		fibril_rwlock_read_unlock(&namespace_rwlock);
-		ipc_answer_0(callid, rc);
-		ipc_answer_0(rid, rc);
+		async_answer_0(callid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1077,6 +1076,6 @@
 	if (!node) {
 		fibril_rwlock_read_unlock(&namespace_rwlock);
-		ipc_answer_0(callid, ENOMEM);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -1088,5 +1087,5 @@
 	msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle,
 	    node->index, false, NULL);
-	ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+	async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 	
 	sysarg_t rv;
@@ -1094,5 +1093,5 @@
 	vfs_release_phone(node->fs_handle, fs_phone);
 
-	ipc_answer_0(rid, rv);
+	async_answer_0(rid, rv);
 
 	vfs_node_put(node);
@@ -1106,5 +1105,5 @@
 	int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1118,5 +1117,5 @@
 	fibril_rwlock_write_unlock(&namespace_rwlock);
 	free(path);
-	ipc_answer_0(rid, rc);
+	async_answer_0(rid, rc);
 }
 
@@ -1128,5 +1127,5 @@
 	int rc = async_data_write_accept((void **) &path, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1139,5 +1138,5 @@
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1154,5 +1153,5 @@
 	fibril_rwlock_write_unlock(&namespace_rwlock);
 	vfs_node_put(node);
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -1163,5 +1162,5 @@
 	int rc = async_data_write_accept((void **) &old, true, 0, 0, 0, NULL);
 	if (rc != EOK) {
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1172,5 +1171,5 @@
 	if (rc != EOK) {
 		free(old);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -1182,5 +1181,5 @@
 	
 	if ((!oldc) || (!newc)) {
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		free(old);
 		free(new);
@@ -1201,5 +1200,5 @@
 		 * - oldc and newc are equal.
 		 */
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		free(old);
 		free(new);
@@ -1216,5 +1215,5 @@
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(old);
 		free(new);
@@ -1225,5 +1224,5 @@
 	if (!old_node) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		free(old);
 		free(new);
@@ -1235,5 +1234,5 @@
 	if (!parentc) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(old);
 		free(new);
@@ -1252,5 +1251,5 @@
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(old);
 		free(new);
@@ -1262,5 +1261,5 @@
 	    (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, EXDEV);	/* different file systems */
+		async_answer_0(rid, EXDEV);	/* different file systems */
 		free(old);
 		free(new);
@@ -1280,5 +1279,5 @@
 		if (!new_node) {
 			fibril_rwlock_write_unlock(&namespace_rwlock);
-			ipc_answer_0(rid, ENOMEM);
+			async_answer_0(rid, ENOMEM);
 			free(old);
 			free(new);
@@ -1291,5 +1290,5 @@
 	default:
 		fibril_rwlock_write_unlock(&namespace_rwlock);
-		ipc_answer_0(rid, ENOTEMPTY);
+		async_answer_0(rid, ENOTEMPTY);
 		free(old);
 		free(new);
@@ -1303,5 +1302,5 @@
 		if (new_node)
 			vfs_node_put(new_node);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(old);
 		free(new);
@@ -1320,5 +1319,5 @@
 		if (new_node)
 			vfs_node_put(new_node);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		free(old);
 		free(new);
@@ -1337,5 +1336,5 @@
 	free(old);
 	free(new);
-	ipc_answer_0(rid, EOK);
+	async_answer_0(rid, EOK);
 }
 
@@ -1347,5 +1346,5 @@
 	/* If the file descriptors are the same, do nothing. */
 	if (oldfd == newfd) {
-		ipc_answer_1(rid, EOK, newfd);
+		async_answer_1(rid, EOK, newfd);
 		return;
 	}
@@ -1354,5 +1353,5 @@
 	vfs_file_t *oldfile = vfs_file_get(oldfd);
 	if (!oldfile) {
-		ipc_answer_0(rid, EBADF);
+		async_answer_0(rid, EBADF);
 		return;
 	}
@@ -1373,5 +1372,5 @@
 			vfs_file_put(oldfile);
 			vfs_file_put(newfile);
-			ipc_answer_0(rid, ret);
+			async_answer_0(rid, ret);
 			return;
 		}
@@ -1382,5 +1381,5 @@
 			vfs_file_put(oldfile);
 			vfs_file_put(newfile);
-			ipc_answer_0(rid, ret);
+			async_answer_0(rid, ret);
 			return;
 		}
@@ -1394,7 +1393,7 @@
 	
 	if (ret != EOK)
-		ipc_answer_0(rid, ret);
+		async_answer_0(rid, ret);
 	else
-		ipc_answer_1(rid, EOK, newfd);
+		async_answer_1(rid, EOK, newfd);
 }
 
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 89acf204d409b78538c6c0af3443ecfd1985b922)
+++ uspace/srv/vfs/vfs_register.c	(revision 474afc96f4cf82871a84e1a3c46e6874a6785d0f)
@@ -36,5 +36,4 @@
  */
 
-#include <ipc/ipc.h>
 #include <ipc/services.h>
 #include <async.h>
@@ -122,5 +121,5 @@
 		dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n",
 		    rc);
-		ipc_answer_0(rid, rc);
+		async_answer_0(rid, rc);
 		return;
 	}
@@ -132,5 +131,5 @@
 	if (!fs_info) {
 		dprintf("Could not allocate memory for FS info.\n");
-		ipc_answer_0(rid, ENOMEM);
+		async_answer_0(rid, ENOMEM);
 		return;
 	}
@@ -144,5 +143,5 @@
 	if (!vfs_info_sane(&fs_info->vfs_info)) {
 		free(fs_info);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -160,5 +159,5 @@
 		fibril_mutex_unlock(&fs_head_lock);
 		free(fs_info);
-		ipc_answer_0(rid, EEXISTS);
+		async_answer_0(rid, EEXISTS);
 		return;
 	}
@@ -182,6 +181,6 @@
 		fibril_mutex_unlock(&fs_head_lock);
 		free(fs_info);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -189,5 +188,5 @@
 	phone = IPC_GET_ARG5(call);
 	async_session_create(&fs_info->session, phone, 0);
-	ipc_answer_0(callid, EOK);
+	async_answer_0(callid, EOK);
 	
 	dprintf("Callback connection to FS created.\n");
@@ -203,8 +202,8 @@
 		fibril_mutex_unlock(&fs_head_lock);
 		async_session_destroy(&fs_info->session);
-		ipc_hangup(phone);
-		free(fs_info);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_hangup(phone);
+		free(fs_info);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -218,8 +217,8 @@
 		fibril_mutex_unlock(&fs_head_lock);
 		async_session_destroy(&fs_info->session);
-		ipc_hangup(phone);
-		free(fs_info);
-		ipc_answer_0(callid, EINVAL);
-		ipc_answer_0(rid, EINVAL);
+		async_hangup(phone);
+		free(fs_info);
+		async_answer_0(callid, EINVAL);
+		async_answer_0(rid, EINVAL);
 		return;
 	}
@@ -239,5 +238,5 @@
 	 */
 	fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
-	ipc_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
+	async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
 	
 	fibril_condvar_broadcast(&fs_head_cv);
