Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ HelenOS.config	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -255,4 +255,5 @@
 @ "gcc_native" GNU C Compiler (native)
 @ "icc" Intel C Compiler
+@ "suncc" Sun Studio C Compiler
 @ "clang" Clang
 ! [PLATFORM=amd64|PLATFORM=ia32] COMPILER (choice)
@@ -267,4 +268,5 @@
 @ "gcc_cross" GNU C Compiler (cross-compiler)
 @ "gcc_native" GNU C Compiler (native)
+@ "suncc" Sun Studio C Compiler
 ! [PLATFORM=sparc64] COMPILER (choice)
 
@@ -571,7 +573,4 @@
 ! CONFIG_BINUTILS (n/y)
 
-% Build MSIM binary
-! CONFIG_MSIM (n/y)
-
 % Line debugging information
 ! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y)
Index: abi/include/proc/uarg.h
===================================================================
--- abi/include/proc/uarg.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ abi/include/proc/uarg.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,4 @@
 	void *uspace_entry;
 	void *uspace_stack;
-	size_t uspace_stack_size;
 	
 	void (* uspace_thread_function)();
Index: boot/Makefile.build
===================================================================
--- boot/Makefile.build	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ boot/Makefile.build	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -47,4 +47,8 @@
 	-Werror-implicit-function-declaration -wd170
 
+SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
+	-xnolib -xc99=all -features=extensions \
+	-erroff=E_ZERO_SIZED_STRUCT_UNION
+
 CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
@@ -62,4 +66,5 @@
 	GCC_CFLAGS += -g
 	ICC_CFLAGS += -g
+	SUNCC_CFLAGS += -g
 	CLANG_CFLAGS += -g
 endif
@@ -78,4 +83,10 @@
 	CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
+endif
+
+ifeq ($(COMPILER),suncc)
+	CFLAGS = $(SUNCC_CFLAGS) $(EXTRA_CFLAGS)
+	DEFS += $(CONFIG_DEFS)
+	DEPEND_DEFS = $(DEFS)
 endif
 
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ boot/Makefile.common	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -201,9 +201,4 @@
 endif
 
-ifeq ($(CONFIG_MSIM),y)
-RD_APPS_NON_ESSENTIAL += \
-	$(USPACE_PATH)/app/msim/msim
-endif
-
 COMPONENTS = \
 	$(KERNEL_PATH)/kernel.bin \
Index: boot/Makefile.grub
===================================================================
--- boot/Makefile.grub	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ boot/Makefile.grub	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -60,5 +60,5 @@
 build_dist: clean
 	mkdir -p $(BOOT)
-	cp -r -L $(GRUB) $(BOOT)/grub
+	cp -r $(GRUB) $(BOOT)/grub
 ifeq ($(GRUB_ARCH),efi)
 	gunzip $(IMAGE)
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/Makefile	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -103,4 +103,8 @@
 	-Werror-implicit-function-declaration -wd170
 
+SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
+	-xnolib -xc99=all -features=extensions \
+	-erroff=E_ZERO_SIZED_STRUCT_UNION
+
 CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
@@ -122,4 +126,5 @@
 	GCC_CFLAGS += -g
 	ICC_CFLAGS += -g
+	SUNCC_CFLAGS += -g
 	CLANG_CFLAGS += -g
 endif
@@ -175,4 +180,11 @@
 	CFLAGS = $(ICC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
+	INSTRUMENTATION =
+endif
+
+ifeq ($(COMPILER),suncc)
+	CFLAGS = $(SUNCC_CFLAGS)
+	DEFS += $(CONFIG_DEFS)
+	DEPEND_DEFS = $(DEFS)
 	INSTRUMENTATION =
 endif
Index: kernel/arch/abs32le/include/mm/page.h
===================================================================
--- kernel/arch/abs32le/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/abs32le/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -105,12 +105,4 @@
 	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
 
-/* Set PTE present bit accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i)	\
-	set_pt_present((pte_t *) (ptl0), (size_t) (i))
-#define SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT_ARCH(ptl2, i)
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_present((pte_t *) (ptl3), (size_t) (i))
-
 /* Macros for querying the last level entries. */
 #define PTE_VALID_ARCH(p) \
@@ -181,13 +173,4 @@
 }
 
-NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
-    WRITES(ARRAY_RANGE(pt, PTL0_ENTRIES_ARCH))
-    REQUIRES_ARRAY_MUTABLE(pt, PTL0_ENTRIES_ARCH)
-{
-	pte_t *p = &pt[i];
-
-	p->present = 1;
-}
-
 extern void page_arch_init(void);
 extern void page_fault(unsigned int, istate_t *);
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/amd64/Makefile.inc	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -55,4 +55,5 @@
 GCC_CFLAGS += $(CMN1)
 ICC_CFLAGS += $(CMN1)
+SUNCC_CFLAGS += -m64 -xmodel=kernel
 
 BITS = 64
@@ -66,4 +67,5 @@
 	GCC_CFLAGS += $(CMN2)
 	ICC_CFLAGS += $(CMN2)
+	SUNCC_CFLAGS += -xtarget=opteron
 endif
 
Index: kernel/arch/amd64/include/mm/page.h
===================================================================
--- kernel/arch/amd64/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/amd64/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -119,14 +119,4 @@
 	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
 
-/* Set PTE present bit accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
-	set_pt_present((pte_t *) (ptl0), (size_t) (i))
-#define SET_PTL2_PRESENT_ARCH(ptl1, i) \
-	set_pt_present((pte_t *) (ptl1), (size_t) (i))
-#define SET_PTL3_PRESENT_ARCH(ptl2, i) \
-	set_pt_present((pte_t *) (ptl2), (size_t) (i))
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_present((pte_t *) (ptl3), (size_t) (i))
-
 /* Macros for querying the last-level PTE entries. */
 #define PTE_VALID_ARCH(p) \
@@ -225,11 +215,4 @@
 }
 
-NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
-{
-	pte_t *p = &pt[i];
-
-	p->present = 1;
-}
-
 extern void page_arch_init(void);
 extern void page_fault(unsigned int, istate_t *);
Index: kernel/arch/amd64/src/mm/page.c
===================================================================
--- kernel/arch/amd64/src/mm/page.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/amd64/src/mm/page.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -57,5 +57,5 @@
 	uintptr_t cur;
 	unsigned int identity_flags =
-	    PAGE_GLOBAL | PAGE_CACHEABLE | PAGE_EXEC | PAGE_WRITE | PAGE_READ;
+	    PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL | PAGE_WRITE;
 		
 	page_mapping_operations = &pt_mapping_operations;
Index: kernel/arch/amd64/src/userspace.c
===================================================================
--- kernel/arch/amd64/src/userspace.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/amd64/src/userspace.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -55,5 +55,5 @@
 	asm volatile (
 		"pushq %[udata_des]\n"
-		"pushq %[stack_top]\n"
+		"pushq %[stack_size]\n"
 		"pushq %[ipl]\n"
 		"pushq %[utext_des]\n"
@@ -65,6 +65,5 @@
 		"iretq\n"
 		:: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
-		   [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
-		       kernel_uarg->uspace_stack_size),
+		   [stack_size] "r" (kernel_uarg->uspace_stack + STACK_SIZE),
 		   [ipl] "r" (ipl),
 		   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
@@ -75,5 +74,6 @@
 	
 	/* Unreachable */
-	while (1);
+	while (1)
+		;
 }
 
Index: kernel/arch/arm32/include/mm/page.h
===================================================================
--- kernel/arch/arm32/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/arm32/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,4 @@
 #include <mm/mm.h>
 #include <arch/exception.h>
-#include <arch/barrier.h>
 #include <trace.h>
 
@@ -110,12 +109,4 @@
 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
 	set_pt_level1_flags((pte_t *) (ptl3), (size_t) (i), (x))
-
-/* Set PTE present bit accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
-	set_pt_level0_present((pte_t *) (ptl0), (size_t) (i))
-#define SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT_ARCH(ptl2, i)
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_level1_present((pte_t *) (ptl3), (size_t) (i))
 
 /* Macros for querying the last-level PTE entries. */
@@ -276,12 +267,4 @@
 }
 
-NO_TRACE static inline void set_pt_level0_present(pte_t *pt, size_t i)
-{
-	pte_level0_t *p = &pt[i].l0;
-
-	p->should_be_zero = 0;
-	write_barrier();
-	p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
-}
 
 /** Sets flags of level 1 page table entry.
@@ -300,8 +283,11 @@
 	pte_level1_t *p = &pt[i].l1;
 	
-	if (flags & PAGE_NOT_PRESENT)
+	if (flags & PAGE_NOT_PRESENT) {
 		p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
-	else
+		p->access_permission_3 = 1;
+	} else {
 		p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
+		p->access_permission_3 = p->access_permission_0;
+	}
 	
 	p->cacheable = p->bufferable = (flags & PAGE_CACHEABLE) != 0;
@@ -326,13 +312,8 @@
 }
 
-NO_TRACE static inline void set_pt_level1_present(pte_t *pt, size_t i)
-{
-	pte_level1_t *p = &pt[i].l1;
-
-	p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
-}
-	
+
 extern void page_arch_init(void);
 
+
 #endif /* __ASM__ */
 
Index: kernel/arch/arm32/src/userspace.c
===================================================================
--- kernel/arch/arm32/src/userspace.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/arm32/src/userspace.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -92,6 +92,5 @@
 
 	/* set user stack */
-	ustate.sp = ((uint32_t) kernel_uarg->uspace_stack) +
-	    kernel_uarg->uspace_stack_size;
+	ustate.sp = ((uint32_t)kernel_uarg->uspace_stack) + STACK_SIZE;
 
 	/* set where uspace execution starts */
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia32/Makefile.inc	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -38,4 +38,5 @@
 GCC_CFLAGS += $(CMN1)
 ICC_CFLAGS += $(CMN1)
+SUNCC_CFLAGS += $(CMN1)
 CLANG_CFLAGS += $(CMN1)
 
@@ -49,20 +50,25 @@
 ifeq ($(PROCESSOR),athlon_xp)
 	CMN2 = -march=athlon-xp
+	SUNCC_CFLAGS += -xarch=ssea
 endif
 
 ifeq ($(PROCESSOR),athlon_mp)
 	CMN2 = -march=athlon-mp
+	SUNCC_CFLAGS += xarch=ssea
 endif
 
 ifeq ($(PROCESSOR),pentium3)
 	CMN2 = -march=pentium3
+	SUNCC_CFLAGS += -xarch=sse
 endif
 
 ifeq ($(PROCESSOR),pentium4)
 	CMN2 = -march=pentium4
+	SUNCC_CFLAGS += -xarch=sse2
 endif
 
 ifeq ($(PROCESSOR),core)
 	CMN2 = -march=prescott
+	SUNCC_CFLAGS += -xarch=sse3
 endif
 
Index: kernel/arch/ia32/include/mm/page.h
===================================================================
--- kernel/arch/ia32/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia32/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -115,12 +115,4 @@
 	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
 
-/* Set PTE present bit accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
-	set_pt_present((pte_t *) (ptl0), (size_t) (i))
-#define SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT_ARCH(ptl2, i)
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_present((pte_t *) (ptl3), (size_t) (i))
-
 /* Macros for querying the last level entries. */
 #define PTE_VALID_ARCH(p) \
@@ -202,11 +194,4 @@
 }
 
-NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
-{
-	pte_t *p = &pt[i];
-
-	p->present = 1;
-}
-
 extern void page_arch_init(void);
 extern void page_fault(unsigned int, istate_t *);
Index: kernel/arch/ia32/src/mm/page.c
===================================================================
--- kernel/arch/ia32/src/mm/page.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia32/src/mm/page.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -71,5 +71,8 @@
 	for (cur = 0; cur < min(config.identity_size, config.physmem_end);
 	    cur += FRAME_SIZE) {
-		flags = PAGE_GLOBAL | PAGE_CACHEABLE | PAGE_WRITE | PAGE_READ;
+		flags = PAGE_CACHEABLE | PAGE_WRITE;
+		if ((PA2KA(cur) >= config.base) &&
+		    (PA2KA(cur) < config.base + config.kernel_size))
+			flags |= PAGE_GLOBAL;
 		page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
 	}
Index: kernel/arch/ia32/src/smp/apic.c
===================================================================
--- kernel/arch/ia32/src/smp/apic.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia32/src/smp/apic.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -259,24 +259,4 @@
 }
 
-#define DELIVS_PENDING_SILENT_RETRIES	4	
-
-static void l_apic_wait_for_delivery(void)
-{
-	icr_t icr;
-	unsigned retries = 0;
-
-	do {
-		if (retries++ > DELIVS_PENDING_SILENT_RETRIES) {
-			retries = 0;
-#ifdef CONFIG_DEBUG
-			printf("IPI is pending.\n");
-#endif
-			delay(20);
-		}
-		icr.lo = l_apic[ICRlo];
-	} while (icr.delivs == DELIVS_PENDING);
-	
-}
-
 /** Send all CPUs excluding CPU IPI vector.
  *
@@ -299,6 +279,11 @@
 	
 	l_apic[ICRlo] = icr.lo;
-
-	l_apic_wait_for_delivery();
+	
+	icr.lo = l_apic[ICRlo];
+	if (icr.delivs == DELIVS_PENDING) {
+#ifdef CONFIG_DEBUG
+		printf("IPI is pending.\n");
+#endif
+	}
 	
 	return apic_poll_errors();
@@ -342,7 +327,11 @@
 		return 0;
 	
-	l_apic_wait_for_delivery();
-
 	icr.lo = l_apic[ICRlo];
+	if (icr.delivs == DELIVS_PENDING) {
+#ifdef CONFIG_DEBUG
+		printf("IPI is pending.\n");
+#endif
+	}
+	
 	icr.delmod = DELMOD_INIT;
 	icr.destmod = DESTMOD_PHYS;
Index: kernel/arch/ia32/src/userspace.c
===================================================================
--- kernel/arch/ia32/src/userspace.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia32/src/userspace.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -63,5 +63,5 @@
 		
 		"pushl %[udata_des]\n"
-		"pushl %[stack_top]\n"
+		"pushl %[stack_size]\n"
 		"pushl %[ipl]\n"
 		"pushl %[utext_des]\n"
@@ -75,6 +75,5 @@
 		:
 		: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
-		  [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
-		      kernel_uarg->uspace_stack_size),
+		  [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + STACK_SIZE),
 		  [ipl] "r" (ipl),
 		  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
Index: kernel/arch/ia64/src/drivers/ski.c
===================================================================
--- kernel/arch/ia64/src/drivers/ski.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia64/src/drivers/ski.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -150,6 +150,6 @@
 	
 	if (instance) {
-		instance->thread = thread_create(kskipoll, instance, TASK,
-		    THREAD_FLAG_UNCOUNTED, "kskipoll");
+		instance->thread = thread_create(kskipoll, instance, TASK, 0,
+		    "kskipoll", true);
 		
 		if (!instance->thread) {
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ia64/src/ia64.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -232,16 +232,14 @@
 	 *
 	 * When calculating stack addresses, mind the stack split between the
-	 * memory stack and the RSE stack. Each occuppies
-	 * uspace_stack_size / 2 bytes.
+	 * memory stack and the RSE stack. Each occuppies STACK_SIZE / 2 bytes.
 	 */
 	switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
-	    ((uintptr_t) kernel_uarg->uspace_stack) +
-	    kernel_uarg->uspace_stack_size / 2 -
+	    ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2 -
 	    ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
-	    ((uintptr_t) kernel_uarg->uspace_stack) +
-	    kernel_uarg->uspace_stack_size / 2,
+	    ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2,
 	    (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value);
-	
-	while (1);
+
+	while (1)
+		;
 }
 
Index: kernel/arch/mips32/include/mm/page.h
===================================================================
--- kernel/arch/mips32/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/mips32/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -128,12 +128,4 @@
 	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
 
-/* Set PTE present bit accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
-	set_pt_present((pte_t *) (ptl0), (size_t) (i))
-#define SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT_ARCH(ptl2, i)
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_present((pte_t *) (ptl3), (size_t) (i))
-
 /* Last-level info macros. */
 #define PTE_VALID_ARCH(pte)			(*((uint32_t *) (pte)) != 0)
@@ -190,12 +182,4 @@
 }
 
-NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
-{
-	pte_t *p = &pt[i];
-
-	p->p = 1;
-}
-	
-
 extern void page_arch_init(void);
 
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/mips32/src/mips32.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -211,6 +211,5 @@
 	    cp0_status_um_bit | cp0_status_ie_enabled_bit));
 	cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
-	userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
-	    kernel_uarg->uspace_stack_size),
+	userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE),
 	    (uintptr_t) kernel_uarg->uspace_uarg,
 	    (uintptr_t) kernel_uarg->uspace_entry);
Index: kernel/arch/mips64/src/mips64.c
===================================================================
--- kernel/arch/mips64/src/mips64.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/mips64/src/mips64.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -188,6 +188,5 @@
 	    cp0_status_um_bit | cp0_status_ie_enabled_bit));
 	cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
-	userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
-	    kernel_uarg->uspace_stack_size),
+	userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE),
 	    (uintptr_t) kernel_uarg->uspace_uarg,
 	    (uintptr_t) kernel_uarg->uspace_entry);
Index: kernel/arch/ppc32/include/mm/page.h
===================================================================
--- kernel/arch/ppc32/include/mm/page.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ppc32/include/mm/page.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -129,14 +129,4 @@
 	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
 
-/* Set PTE present accessors for each level. */
-#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
-	set_pt_present((pte_t *) (ptl0), (size_t) (i))
-
-#define SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT_ARCH(ptl2, i)
-
-#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
-	set_pt_present((pte_t *) (ptl3), (size_t) (i))
-
 /* Macros for querying the last-level PTEs. */
 #define PTE_VALID_ARCH(pte)       (*((uint32_t *) (pte)) != 0)
@@ -185,11 +175,4 @@
 }
 
-NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
-{
-	pte_t *entry = &pt[i];
-
-	entry->present = 1;
-}
-
 extern void page_arch_init(void);
 
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/ppc32/src/ppc32.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -269,6 +269,5 @@
 {
 	userspace_asm((uintptr_t) kernel_uarg->uspace_uarg,
-	    (uintptr_t) kernel_uarg->uspace_stack +
-	    kernel_uarg->uspace_stack_size - SP_DELTA,
+	    (uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE - SP_DELTA,
 	    (uintptr_t) kernel_uarg->uspace_entry);
 	
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/Makefile.inc	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -32,4 +32,5 @@
 
 GCC_CFLAGS += -m64 -mcpu=ultrasparc -mcmodel=medlow -mno-fpu
+SUNCC_CFLAGS += -m64 -xarch=sparc -xregs=appl,no%float
 
 LFLAGS += -no-check-sections
Index: kernel/arch/sparc64/src/drivers/niagara.c
===================================================================
--- kernel/arch/sparc64/src/drivers/niagara.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/drivers/niagara.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -184,6 +184,6 @@
 	
 	instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC);
-	instance->thread = thread_create(kniagarapoll, NULL, TASK,
-	    THREAD_FLAG_UNCOUNTED, "kniagarapoll");
+	instance->thread = thread_create(kniagarapoll, NULL, TASK, 0,
+	    "kniagarapoll", true);
 	
 	if (!instance->thread) {
Index: kernel/arch/sparc64/src/proc/sun4u/scheduler.c
===================================================================
--- kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -51,5 +51,5 @@
 void before_thread_runs_arch(void)
 {
-	if (THREAD->uspace) {
+	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
 		/*
 		 * Write kernel stack address to %g6 of the alternate and
@@ -74,6 +74,6 @@
 void after_thread_ran_arch(void)
 {
-	if (THREAD->uspace) {
-		/* sample the state of the userspace window buffer */
+	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
+		/* sample the state of the userspace window buffer */	
 		THREAD->arch.uspace_window_buffer = (uint8_t *) read_from_ag_g7();
 	}
Index: kernel/arch/sparc64/src/proc/sun4v/scheduler.c
===================================================================
--- kernel/arch/sparc64/src/proc/sun4v/scheduler.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/proc/sun4v/scheduler.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -54,5 +54,5 @@
 void before_thread_runs_arch(void)
 {
-	if (THREAD->uspace) {
+	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
 		uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE -
 		    (STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT));
@@ -66,6 +66,6 @@
 void after_thread_ran_arch(void)
 {
-	if (THREAD->uspace) {
-		/* sample the state of the userspace window buffer */
+	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
+		/* sample the state of the userspace window buffer */	
 		THREAD->arch.uspace_window_buffer =
 		    (uint8_t *) asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_WBUF);
Index: kernel/arch/sparc64/src/proc/thread.c
===================================================================
--- kernel/arch/sparc64/src/proc/thread.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/proc/thread.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -61,5 +61,5 @@
 void thread_create_arch(thread_t *t)
 {
-	if ((t->uspace) && (!t->arch.uspace_window_buffer))
+	if ((t->flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer))
 		{
 		/*
Index: kernel/arch/sparc64/src/smp/sun4u/ipi.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4u/ipi.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/smp/sun4u/ipi.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -124,5 +124,5 @@
 			(void) interrupts_disable();
 		}
-	} while (!done);
+	} while (done);
 	
 	preemption_enable();
Index: kernel/arch/sparc64/src/sun4u/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sun4u/sparc64.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/sun4u/sparc64.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -156,11 +156,11 @@
 	(void) interrupts_disable();
 	switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
-	    ((uintptr_t) kernel_uarg->uspace_stack) +
-	    kernel_uarg->uspace_stack_size -
-	    (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
+	    ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
+	    - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
 	    (uintptr_t) kernel_uarg->uspace_uarg);
-	
-	/* Not reached */
-	while (1);
+
+	for (;;)
+		;
+	/* not reached */
 }
 
Index: kernel/arch/sparc64/src/sun4v/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sun4v/sparc64.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/arch/sparc64/src/sun4v/sparc64.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -154,11 +154,11 @@
 	(void) interrupts_disable();
 	switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
-	    ((uintptr_t) kernel_uarg->uspace_stack) +
-	    kernel_uarg->uspace_stack_size -
-	    (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
+	    ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
+	    - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
 	    (uintptr_t) kernel_uarg->uspace_uarg);
-	
-	/* Not reached */
-	while (1);
+
+	for (;;)
+		;
+	/* not reached */
 }
 
Index: kernel/genarch/include/mm/page_pt.h
===================================================================
--- kernel/genarch/include/mm/page_pt.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/include/mm/page_pt.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -115,13 +115,4 @@
 
 /*
- * These macros are provided to set the present bit within the page tables.
- *
- */
-#define SET_PTL1_PRESENT(ptl0, i)   SET_PTL1_PRESENT_ARCH(ptl0, i)
-#define SET_PTL2_PRESENT(ptl1, i)   SET_PTL2_PRESENT_ARCH(ptl1, i)
-#define SET_PTL3_PRESENT(ptl2, i)   SET_PTL3_PRESENT_ARCH(ptl2, i)
-#define SET_FRAME_PRESENT(ptl3, i)  SET_FRAME_PRESENT_ARCH(ptl3, i)
-
-/*
  * Macros for querying the last-level PTEs.
  *
Index: kernel/genarch/src/kbrd/kbrd.c
===================================================================
--- kernel/genarch/src/kbrd/kbrd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/src/kbrd/kbrd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -158,6 +158,6 @@
 	    = malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC);
 	if (instance) {
-		instance->thread = thread_create(kkbrd, (void *) instance,
-		    TASK, THREAD_FLAG_NONE, "kkbrd");
+		instance->thread
+			= thread_create(kkbrd, (void *) instance, TASK, 0, "kkbrd", false);
 		
 		if (!instance->thread) {
Index: kernel/genarch/src/mm/as_ht.c
===================================================================
--- kernel/genarch/src/mm/as_ht.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/src/mm/as_ht.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -78,6 +78,6 @@
 		hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations);
 		mutex_initialize(&page_ht_lock, MUTEX_PASSIVE);
-		pte_cache = slab_cache_create("pte_t", sizeof(pte_t), 0,
-		    NULL, NULL, SLAB_CACHE_MAGDEFERRED);
+		pte_cache = slab_cache_create("pte_cache", sizeof(pte_t), 0, NULL, NULL,
+		    SLAB_CACHE_MAGDEFERRED);
 	}
 	
Index: kernel/genarch/src/mm/page_ht.c
===================================================================
--- kernel/genarch/src/mm/page_ht.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/src/mm/page_ht.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -45,5 +45,4 @@
 #include <typedefs.h>
 #include <arch/asm.h>
-#include <arch/barrier.h>
 #include <synch/spinlock.h>
 #include <arch.h>
@@ -208,6 +207,4 @@
 		pte->page = ALIGN_DOWN(page, PAGE_SIZE);
 		pte->frame = ALIGN_DOWN(frame, FRAME_SIZE);
-
-		write_barrier();
 		
 		hash_table_insert(&page_ht, key, &pte->link);
Index: kernel/genarch/src/mm/page_pt.c
===================================================================
--- kernel/genarch/src/mm/page_pt.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/src/mm/page_pt.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,5 +43,4 @@
 #include <arch/mm/page.h>
 #include <arch/mm/as.h>
-#include <arch/barrier.h>
 #include <typedefs.h>
 #include <arch/asm.h>
@@ -87,8 +86,6 @@
 		SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
 		SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page),
-		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
+		    PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		write_barrier();
-		SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page));
 	}
 	
@@ -101,8 +98,6 @@
 		SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
 		SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page),
-		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
+		    PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		write_barrier();
-		SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page));	
 	}
 	
@@ -115,8 +110,6 @@
 		SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
 		SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page),
-		    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
+		    PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
 		    PAGE_WRITE);
-		write_barrier();
-		SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page));
 	}
 	
@@ -124,7 +117,5 @@
 	
 	SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
-	SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT);
-	write_barrier();
-	SET_FRAME_PRESENT(ptl3, PTL3_INDEX(page));
+	SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags);
 }
 
@@ -288,22 +279,12 @@
 	if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
 		return NULL;
-
-	read_barrier();
 	
 	pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
 	if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
 		return NULL;
-
-#if (PTL1_ENTRIES != 0)
-	read_barrier();
-#endif
 	
 	pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
 	if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
 		return NULL;
-
-#if (PTL2_ENTRIES != 0)
-	read_barrier();
-#endif
 	
 	pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
@@ -365,6 +346,6 @@
 		SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1));
 		SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
-		    PAGE_PRESENT | PAGE_USER | PAGE_CACHEABLE |
-		    PAGE_EXEC | PAGE_WRITE | PAGE_READ);
+		    PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
+		    PAGE_WRITE);
 	}
 }
Index: kernel/genarch/src/srln/srln.c
===================================================================
--- kernel/genarch/src/srln/srln.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/genarch/src/srln/srln.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -130,6 +130,6 @@
 	    = malloc(sizeof(srln_instance_t), FRAME_ATOMIC);
 	if (instance) {
-		instance->thread = thread_create(ksrln, (void *) instance,
-		    TASK, THREAD_FLAG_NONE, "ksrln");
+		instance->thread
+			= thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false);
 		
 		if (!instance->thread) {
Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/include/ipc/ipc.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -148,5 +148,5 @@
 extern int ipc_call(phone_t *, call_t *);
 extern int ipc_call_sync(phone_t *, call_t *);
-extern call_t *ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
+extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int);
 extern void ipc_answer(answerbox_t *, call_t *);
Index: kernel/generic/include/ipc/ipcrsc.h
===================================================================
--- kernel/generic/include/ipc/ipcrsc.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/include/ipc/ipcrsc.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -39,8 +39,8 @@
 #include <ipc/ipc.h>
 
-extern call_t *get_call(sysarg_t);
-extern int phone_alloc(task_t *);
-extern void phone_connect(int, answerbox_t *);
-extern void phone_dealloc(int);
+extern call_t * get_call(sysarg_t callid);
+extern int phone_alloc(task_t *t);
+extern void phone_connect(int phoneid, answerbox_t *box);
+extern void phone_dealloc(int phoneid);
 
 #endif
Index: kernel/generic/include/proc/program.h
===================================================================
--- kernel/generic/include/proc/program.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/include/proc/program.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -50,5 +50,4 @@
 	struct task *task;           /**< Program task */
 	struct thread *main_thread;  /**< Program main thread */
-	unsigned int loader_status;  /**< Binary loader error status */
 } program_t;
 
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/include/proc/thread.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -54,13 +54,21 @@
 
 /* Thread flags */
-typedef enum {
-	THREAD_FLAG_NONE = 0,
-	/** Thread executes in user space. */
-	THREAD_FLAG_USPACE = (1 << 0),
-	/** Thread will be attached by the caller. */
-	THREAD_FLAG_NOATTACH = (1 << 1),
-	/** Thread accounting doesn't affect accumulated task accounting. */
-	THREAD_FLAG_UNCOUNTED = (1 << 2)
-} thread_flags_t;
+
+/** Thread cannot be migrated to another CPU.
+ *
+ * When using this flag, the caller must set cpu in the thread_t
+ * structure manually before calling thread_ready (even on uniprocessor).
+ *
+ */
+#define THREAD_FLAG_WIRED  (1 << 0)
+
+/** Thread was migrated to another CPU and has not run yet. */
+#define THREAD_FLAG_STOLEN  (1 << 1)
+
+/** Thread executes in userspace. */
+#define THREAD_FLAG_USPACE  (1 << 2)
+
+/** Thread will be attached by the caller. */
+#define THREAD_FLAG_NOATTACH  (1 << 3)
 
 /** Thread structure. There is one per thread. */
@@ -139,5 +147,5 @@
 	
 	fpu_context_t *saved_fpu_context;
-	bool fpu_context_exists;
+	int fpu_context_exists;
 	
 	/*
@@ -146,22 +154,18 @@
 	 * thread. This disables migration.
 	 */
-	bool fpu_context_engaged;
+	int fpu_context_engaged;
 	
 	/* The thread will not be migrated if nomigrate is non-zero. */
-	unsigned int nomigrate;
-	
-	/** Thread state. */
+	int nomigrate;
+	
+	/** Thread's state. */
 	state_t state;
-	
-	/** Thread CPU. */
+	/** Thread's flags. */
+	unsigned int flags;
+	
+	/** Thread's CPU. */
 	cpu_t *cpu;
 	/** Containing task. */
 	task_t *task;
-	/** Thread is wired to CPU. */
-	bool wired;
-	/** Thread was migrated to another CPU and has not run yet. */
-	bool stolen;
-	/** Thread is executed in user space. */
-	bool uspace;
 	
 	/** Ticks before preemption. */
@@ -212,6 +216,5 @@
 extern void thread_init(void);
 extern thread_t *thread_create(void (*)(void *), void *, task_t *,
-    thread_flags_t, const char *);
-extern void thread_wire(thread_t *, cpu_t *);
+    unsigned int, const char *, bool);
 extern void thread_attach(thread_t *, task_t *);
 extern void thread_ready(thread_t *);
Index: kernel/generic/src/adt/btree.c
===================================================================
--- kernel/generic/src/adt/btree.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/adt/btree.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -71,5 +71,5 @@
 void btree_init(void)
 {
-	btree_node_slab = slab_cache_create("btree_node_t",
+	btree_node_slab = slab_cache_create("btree_node_slab",
 	    sizeof(btree_node_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 }
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/console/cmd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -724,7 +724,11 @@
 		thread_t *thread;
 		if ((thread = thread_create((void (*)(void *)) cmd_call0,
-		    (void *) argv, TASK, THREAD_FLAG_NONE, "call0"))) {
+		    (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
+			irq_spinlock_lock(&thread->lock, true);
+			thread->cpu = &cpus[i];
+			irq_spinlock_unlock(&thread->lock, true);
+			
 			printf("cpu%u: ", i);
-			thread_wire(thread, &cpus[i]);
+			
 			thread_ready(thread);
 			thread_join(thread);
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/ipc/ipc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -670,7 +670,7 @@
 void ipc_init(void)
 {
-	ipc_call_slab = slab_cache_create("call_t", sizeof(call_t), 0, NULL,
+	ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
 	    NULL, 0);
-	ipc_answerbox_slab = slab_cache_create("answerbox_t",
+	ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
 	    sizeof(answerbox_t), 0, NULL, NULL, 0);
 }
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/ipc/kbox.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -244,6 +244,6 @@
 	
 	/* Create a kbox thread */
-	thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
-	    THREAD_FLAG_NONE, "kbox");
+	thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task, 0,
+	    "kbox", false);
 	if (!kb_thread) {
 		mutex_unlock(&task->kb.cleanup_lock);
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/ipc/sysipc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -597,5 +597,5 @@
 	if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) {
 		int phoneid = phone_alloc(TASK);
-		if (phoneid < 0) {  /* Failed to allocate phone */
+		if (phoneid < 0) { /* Failed to allocate phone */
 			IPC_SET_RETVAL(call->data, ELIMIT);
 			ipc_answer(box, call);
@@ -883,7 +883,7 @@
 	
 	/*
-	 * User space is not allowed to change interface and method of system
+	 * Userspace is not allowed to change interface and method of system
 	 * methods on forward, allow changing ARG1, ARG2, ARG3 and ARG4 by
-	 * means of imethod, arg1, arg2 and arg3.
+	 * means of method, arg1, arg2 and arg3.
 	 * If the interface and method is immutable, don't change anything.
 	 */
@@ -897,11 +897,11 @@
 			IPC_SET_ARG3(call->data, arg2);
 			
-			if (slow)
+			if (slow) {
 				IPC_SET_ARG4(call->data, arg3);
-			
-			/*
-			 * For system methods we deliberately don't
-			 * overwrite ARG5.
-			 */
+				/*
+				 * For system methods we deliberately don't
+				 * overwrite ARG5.
+				 */
+			}
 		} else {
 			IPC_SET_IMETHOD(call->data, imethod);
Index: kernel/generic/src/lib/ra.c
===================================================================
--- kernel/generic/src/lib/ra.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/lib/ra.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -424,5 +424,5 @@
 void ra_init(void)
 {
-	ra_segment_cache = slab_cache_create("ra_segment_t",
+	ra_segment_cache = slab_cache_create("segment_cache",
 	    sizeof(ra_segment_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 }
Index: kernel/generic/src/lib/rd.c
===================================================================
--- kernel/generic/src/lib/rd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/lib/rd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -38,5 +38,4 @@
  */
 
-#include <print.h>
 #include <lib/rd.h>
 #include <mm/frame.h>
@@ -67,6 +66,4 @@
 	sysinfo_set_item_val("rd.size", NULL, size);
 	sysinfo_set_item_val("rd.address.physical", NULL, (sysarg_t) base);
-	
-	printf("RAM disk at %p (size %zu bytes)\n", (void *) base, size);
 }
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/main/kinit.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -116,8 +116,9 @@
 		 * Just a beautification.
 		 */
-		thread = thread_create(kmp, NULL, TASK,
-		    THREAD_FLAG_UNCOUNTED, "kmp");
+		thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
 		if (thread != NULL) {
-			thread_wire(thread, &cpus[0]);
+			irq_spinlock_lock(&thread->lock, false);
+			thread->cpu = &cpus[0];
+			irq_spinlock_unlock(&thread->lock, false);
 			thread_ready(thread);
 		} else
@@ -133,8 +134,9 @@
 		
 		for (i = 0; i < config.cpu_count; i++) {
-			thread = thread_create(kcpulb, NULL, TASK,
-			    THREAD_FLAG_UNCOUNTED, "kcpulb");
+			thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
 			if (thread != NULL) {
-				thread_wire(thread, &cpus[i]);
+				irq_spinlock_lock(&thread->lock, false);
+				thread->cpu = &cpus[i];
+				irq_spinlock_unlock(&thread->lock, false);
 				thread_ready(thread);
 			} else
@@ -150,6 +152,5 @@
 	
 	/* Start thread computing system load */
-	thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
-	    "kload");
+	thread = thread_create(kload, NULL, TASK, 0, "kload", false);
 	if (thread != NULL)
 		thread_ready(thread);
@@ -162,6 +163,5 @@
 		 * Create kernel console.
 		 */
-		thread = thread_create(kconsole_thread, NULL, TASK,
-		    THREAD_FLAG_NONE, "kconsole");
+		thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false);
 		if (thread != NULL)
 			thread_ready(thread);
@@ -201,5 +201,5 @@
 		str_cpy(namebuf + INIT_PREFIX_LEN,
 		    TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name);
-		
+
 		/*
 		 * Create virtual memory mappings for init task images.
@@ -236,7 +236,5 @@
 			init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
 		} else
-			printf("init[%zu]: Init binary load failed "
-			    "(error %d, loader status %u)\n", i, rc,
-			    programs[i].loader_status);
+			printf("init[%zu]: Init binary load failed (error %d)\n", i, rc);
 	}
 	
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/main/main.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -276,6 +276,6 @@
 	 * Create the first thread.
 	 */
-	thread_t *kinit_thread = thread_create(kinit, NULL, kernel,
-	    THREAD_FLAG_UNCOUNTED, "kinit");
+	thread_t *kinit_thread =
+	    thread_create(kinit, NULL, kernel, 0, "kinit", true);
 	if (!kinit_thread)
 		panic("Cannot create kinit thread.");
Index: kernel/generic/src/main/uinit.c
===================================================================
--- kernel/generic/src/main/uinit.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/main/uinit.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -56,4 +56,6 @@
 void uinit(void *arg)
 {
+	uspace_arg_t uarg;
+	
 	/*
 	 * So far, we don't have a use for joining userspace threads so we
@@ -70,17 +72,13 @@
 #endif
 	
-	uspace_arg_t *uarg = (uspace_arg_t *) arg;
-	uspace_arg_t local_uarg;
+	uarg.uspace_entry = ((uspace_arg_t *) arg)->uspace_entry;
+	uarg.uspace_stack = ((uspace_arg_t *) arg)->uspace_stack;
+	uarg.uspace_uarg = ((uspace_arg_t *) arg)->uspace_uarg;
+	uarg.uspace_thread_function = NULL;
+	uarg.uspace_thread_arg = NULL;
 	
-	local_uarg.uspace_entry = uarg->uspace_entry;
-	local_uarg.uspace_stack = uarg->uspace_stack;
-	local_uarg.uspace_stack_size = uarg->uspace_stack_size;
-	local_uarg.uspace_uarg = uarg->uspace_uarg;
-	local_uarg.uspace_thread_function = NULL;
-	local_uarg.uspace_thread_arg = NULL;
+	free((uspace_arg_t *) arg);
 	
-	free(uarg);
-	
-	userspace(&local_uarg);
+	userspace(&uarg);
 }
 
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/mm/as.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -130,5 +130,5 @@
 	as_arch_init();
 	
-	as_slab = slab_cache_create("as_t", sizeof(as_t), 0,
+	as_slab = slab_cache_create("as_slab", sizeof(as_t), 0,
 	    as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
 	
@@ -665,4 +665,10 @@
 		
 		page_table_lock(as, false);
+		
+		/*
+		 * Start TLB shootdown sequence.
+		 */
+		ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid,
+		    area->base + P2SZ(pages), area->pages - pages);
 		
 		/*
@@ -720,20 +726,4 @@
 				}
 				
-				/*
-				 * Start TLB shootdown sequence.
-				 *
-				 * The sequence is rather short and can be
-				 * repeated multiple times. The reason is that
-				 * we don't want to have used_space_remove()
-				 * inside the sequence as it may use a blocking
-				 * memory allocation for its B+tree. Blocking
-				 * while holding the tlblock spinlock is
-				 * forbidden and would hit a kernel assertion.
-				 */
-
-				ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES,
-				    as->asid, area->base + P2SZ(pages),
-				    area->pages - pages);
-		
 				for (; i < size; i++) {
 					pte_t *pte = page_mapping_find(as,
@@ -753,23 +743,22 @@
 					page_mapping_remove(as, ptr + P2SZ(i));
 				}
-		
-				/*
-				 * Finish TLB shootdown sequence.
-				 */
-		
-				tlb_invalidate_pages(as->asid,
-				    area->base + P2SZ(pages),
-				    area->pages - pages);
-		
-				/*
-				 * Invalidate software translation caches
-				 * (e.g. TSB on sparc64, PHT on ppc32).
-				 */
-				as_invalidate_translation_cache(as,
-				    area->base + P2SZ(pages),
-				    area->pages - pages);
-				tlb_shootdown_finalize(ipl);
 			}
 		}
+		
+		/*
+		 * Finish TLB shootdown sequence.
+		 */
+		
+		tlb_invalidate_pages(as->asid, area->base + P2SZ(pages),
+		    area->pages - pages);
+		
+		/*
+		 * Invalidate software translation caches
+		 * (e.g. TSB on sparc64, PHT on ppc32).
+		 */
+		as_invalidate_translation_cache(as, area->base + P2SZ(pages),
+		    area->pages - pages);
+		tlb_shootdown_finalize(ipl);
+		
 		page_table_unlock(as, false);
 	} else {
Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/mm/slab.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -891,5 +891,5 @@
 {
 	/* Initialize magazine cache */
-	_slab_cache_create(&mag_cache, "slab_magazine_t",
+	_slab_cache_create(&mag_cache, "slab_magazine",
 	    sizeof(slab_magazine_t) + SLAB_MAG_SIZE * sizeof(void*),
 	    sizeof(uintptr_t), NULL, NULL, SLAB_CACHE_NOMAGAZINE |
@@ -897,10 +897,10 @@
 	
 	/* Initialize slab_cache cache */
-	_slab_cache_create(&slab_cache_cache, "slab_cache_cache",
+	_slab_cache_create(&slab_cache_cache, "slab_cache",
 	    sizeof(slab_cache_cache), sizeof(uintptr_t), NULL, NULL,
 	    SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE);
 	
 	/* Initialize external slab cache */
-	slab_extern_cache = slab_cache_create("slab_t", sizeof(slab_t), 0,
+	slab_extern_cache = slab_cache_create("slab_extern", sizeof(slab_t), 0,
 	    NULL, NULL, SLAB_CACHE_SLINSIDE | SLAB_CACHE_MAGDEFERRED);
 	
Index: kernel/generic/src/mm/tlb.c
===================================================================
--- kernel/generic/src/mm/tlb.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/mm/tlb.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -162,5 +162,5 @@
 	
 	size_t i;
-	for (i = 0; i < CPU->tlb_messages_count; i++) {
+	for (i = 0; i < CPU->tlb_messages_count; CPU->tlb_messages_count--) {
 		tlb_invalidate_type_t type = CPU->tlb_messages[i].type;
 		asid_t asid = CPU->tlb_messages[i].asid;
@@ -188,5 +188,4 @@
 	}
 	
-	CPU->tlb_messages_count = 0;
 	irq_spinlock_unlock(&CPU->lock, false);
 	CPU->tlb_active = true;
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/proc/program.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -71,5 +71,13 @@
 int program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *prg)
 {
-	prg->loader_status = EE_OK;
+	uspace_arg_t *kernel_uarg;
+	
+	kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
+	kernel_uarg->uspace_entry = (void *) entry_addr;
+	kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;
+	kernel_uarg->uspace_thread_function = NULL;
+	kernel_uarg->uspace_thread_arg = NULL;
+	kernel_uarg->uspace_uarg = NULL;
+	
 	prg->task = task_create(as, name);
 	if (!prg->task)
@@ -83,18 +91,6 @@
 	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
 	    STACK_SIZE, AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, 0);
-	if (!area) {
-		task_destroy(prg->task);
+	if (!area)
 		return ENOMEM;
-	}
-	
-	uspace_arg_t *kernel_uarg = (uspace_arg_t *)
-	    malloc(sizeof(uspace_arg_t), 0);
-	
-	kernel_uarg->uspace_entry = (void *) entry_addr;
-	kernel_uarg->uspace_stack = (void *) virt;
-	kernel_uarg->uspace_stack_size = STACK_SIZE;
-	kernel_uarg->uspace_thread_function = NULL;
-	kernel_uarg->uspace_thread_arg = NULL;
-	kernel_uarg->uspace_uarg = NULL;
 	
 	/*
@@ -102,11 +98,7 @@
 	 */
 	prg->main_thread = thread_create(uinit, kernel_uarg, prg->task,
-	    THREAD_FLAG_USPACE, "uinit");
-	if (!prg->main_thread) {
-		free(kernel_uarg);
-		as_area_destroy(as, virt);
-		task_destroy(prg->task);
+	    THREAD_FLAG_USPACE, "uinit", false);
+	if (!prg->main_thread)
 		return ELIMIT;
-	}
 	
 	return EOK;
@@ -119,10 +111,9 @@
  * executable image. The task is returned in *task.
  *
- * @param[in]  image_addr Address of an executable program image.
- * @param[in]  name       Name to set for the program's task.
- * @param[out] prg        Buffer for storing program info.
- *                        If image_addr points to a loader image,
- *                        prg->task will be set to NULL and EOK
- *                        will be returned.
+ * @param image_addr Address of an executable program image.
+ * @param name       Name to set for the program's task.
+ * @param prg        Buffer for storing program info. If image_addr
+ *                   points to a loader image, p->task will be set to
+ *                   NULL and EOK will be returned.
  *
  * @return EOK on success or negative error code.
@@ -135,11 +126,11 @@
 		return ENOMEM;
 	
-	prg->loader_status = elf_load((elf_header_t *) image_addr, as, 0);
-	if (prg->loader_status != EE_OK) {
+	unsigned int rc = elf_load((elf_header_t *) image_addr, as, 0);
+	if (rc != EE_OK) {
 		as_destroy(as);
 		prg->task = NULL;
 		prg->main_thread = NULL;
 		
-		if (prg->loader_status != EE_LOADER)
+		if (rc != EE_LOADER)
 			return ENOTSUP;
 		
@@ -149,5 +140,6 @@
 		
 		program_loader = image_addr;
-		printf("Program loader at %p\n", (void *) image_addr);
+		LOG("Registered program loader at %p",
+		    (void *) image_addr);
 		
 		return EOK;
@@ -179,10 +171,9 @@
 	}
 	
-	prg->loader_status = elf_load((elf_header_t *) program_loader, as,
+	unsigned int rc = elf_load((elf_header_t *) program_loader, as,
 	    ELD_F_LOADER);
-	if (prg->loader_status != EE_OK) {
+	if (rc != EE_OK) {
 		as_destroy(as);
-		printf("Cannot spawn loader (%s)\n",
-		    elf_error(prg->loader_status));
+		printf("Cannot spawn loader (%s)\n", elf_error(rc));
 		return ENOENT;
 	}
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/proc/scheduler.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -98,5 +98,5 @@
 	else {
 		fpu_init();
-		THREAD->fpu_context_exists = true;
+		THREAD->fpu_context_exists = 1;
 	}
 #endif
@@ -142,5 +142,5 @@
 		
 		/* Don't prevent migration */
-		CPU->fpu_owner->fpu_context_engaged = false;
+		CPU->fpu_owner->fpu_context_engaged = 0;
 		irq_spinlock_unlock(&CPU->fpu_owner->lock, false);
 		CPU->fpu_owner = NULL;
@@ -163,9 +163,9 @@
 		}
 		fpu_init();
-		THREAD->fpu_context_exists = true;
+		THREAD->fpu_context_exists = 1;
 	}
 	
 	CPU->fpu_owner = THREAD;
-	THREAD->fpu_context_engaged = true;
+	THREAD->fpu_context_engaged = 1;
 	irq_spinlock_unlock(&THREAD->lock, false);
 	
@@ -248,8 +248,8 @@
 		
 		/*
-		 * Clear the stolen flag so that it can be migrated
+		 * Clear the THREAD_FLAG_STOLEN flag so that t can be migrated
 		 * when load balancing needs emerge.
 		 */
-		thread->stolen = false;
+		thread->flags &= ~THREAD_FLAG_STOLEN;
 		irq_spinlock_unlock(&thread->lock, false);
 		
@@ -630,7 +630,8 @@
 				irq_spinlock_lock(&thread->lock, false);
 				
-				if ((!thread->wired) && (!thread->stolen) &&
-				    (!thread->nomigrate) &&
-				    (!thread->fpu_context_engaged)) {
+				if (!(thread->flags & THREAD_FLAG_WIRED) &&
+				    !(thread->flags & THREAD_FLAG_STOLEN) &&
+				    !thread->nomigrate &&
+				    !thread->fpu_context_engaged) {
 					/*
 					 * Remove thread from ready queue.
@@ -669,5 +670,5 @@
 #endif
 				
-				thread->stolen = true;
+				thread->flags |= THREAD_FLAG_STOLEN;
 				thread->state = Entering;
 				
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/proc/task.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -90,5 +90,5 @@
 	TASK = NULL;
 	avltree_create(&tasks_tree);
-	task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
+	task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,
 	    tsk_constructor, NULL, 0);
 }
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/proc/thread.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -191,5 +191,5 @@
 	kmflags |= FRAME_LOWMEM;
 	kmflags &= ~FRAME_HIGHMEM;
-	
+
 	thread->kstack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | kmflags);
 	if (!thread->kstack) {
@@ -236,10 +236,10 @@
 	
 	atomic_set(&nrdy, 0);
-	thread_slab = slab_cache_create("thread_t", sizeof(thread_t), 0,
+	thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0,
 	    thr_constructor, thr_destructor, 0);
 	
 #ifdef CONFIG_FPU
-	fpu_context_slab = slab_cache_create("fpu_context_t",
-	    sizeof(fpu_context_t), FPU_CONTEXT_ALIGN, NULL, NULL, 0);
+	fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
+	    FPU_CONTEXT_ALIGN, NULL, NULL, 0);
 #endif
 	
@@ -247,40 +247,25 @@
 }
 
-/** Wire thread to the given CPU
- *
- * @param cpu CPU to wire the thread to.
- *
- */
-void thread_wire(thread_t *thread, cpu_t *cpu)
+/** Make thread ready
+ *
+ * Switch thread to the ready state.
+ *
+ * @param thread Thread to make ready.
+ *
+ */
+void thread_ready(thread_t *thread)
 {
 	irq_spinlock_lock(&thread->lock, true);
-	thread->cpu = cpu;
-	thread->wired = true;
-	irq_spinlock_unlock(&thread->lock, true);
-}
-
-/** Make thread ready
- *
- * Switch thread to the ready state.
- *
- * @param thread Thread to make ready.
- *
- */
-void thread_ready(thread_t *thread)
-{
-	irq_spinlock_lock(&thread->lock, true);
 	
 	ASSERT(thread->state != Ready);
 	
-	int i = (thread->priority < RQ_COUNT - 1) ?
-	    ++thread->priority : thread->priority;
-	
-	cpu_t *cpu;
-	if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) {
+	int i = (thread->priority < RQ_COUNT - 1)
+	    ? ++thread->priority : thread->priority;
+	
+	cpu_t *cpu = CPU;
+	if (thread->flags & THREAD_FLAG_WIRED) {
 		ASSERT(thread->cpu != NULL);
 		cpu = thread->cpu;
-	} else
-		cpu = CPU;
-	
+	}
 	thread->state = Ready;
 	
@@ -313,4 +298,6 @@
  * @param flags     Thread flags.
  * @param name      Symbolic name (a copy is made).
+ * @param uncounted Thread's accounting doesn't affect accumulated task
+ *                  accounting.
  *
  * @return New thread's structure on success, NULL on failure.
@@ -318,5 +305,5 @@
  */
 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
-    thread_flags_t flags, const char *name)
+    unsigned int flags, const char *name, bool uncounted)
 {
 	thread_t *thread = (thread_t *) slab_alloc(thread_slab, 0);
@@ -348,13 +335,8 @@
 	thread->ucycles = 0;
 	thread->kcycles = 0;
-	thread->uncounted =
-	    ((flags & THREAD_FLAG_UNCOUNTED) == THREAD_FLAG_UNCOUNTED);
+	thread->uncounted = uncounted;
 	thread->priority = -1;          /* Start in rq[0] */
 	thread->cpu = NULL;
-	thread->wired = false;
-	thread->stolen = false;
-	thread->uspace =
-	    ((flags & THREAD_FLAG_USPACE) == THREAD_FLAG_USPACE);
-	
+	thread->flags = flags;
 	thread->nomigrate = 0;
 	thread->state = Entering;
@@ -374,6 +356,6 @@
 	thread->task = task;
 	
-	thread->fpu_context_exists = false;
-	thread->fpu_context_engaged = false;
+	thread->fpu_context_exists = 0;
+	thread->fpu_context_engaged = 0;
 	
 	avltree_node_initialize(&thread->threads_tree_node);
@@ -389,5 +371,5 @@
 	thread_create_arch(thread);
 	
-	if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
+	if (!(flags & THREAD_FLAG_NOATTACH))
 		thread_attach(thread, task);
 	
@@ -455,5 +437,5 @@
 	
 	/* Must not count kbox thread into lifecount */
-	if (thread->uspace)
+	if (thread->flags & THREAD_FLAG_USPACE)
 		atomic_inc(&task->lifecount);
 	
@@ -477,9 +459,9 @@
 void thread_exit(void)
 {
-	if (THREAD->uspace) {
+	if (THREAD->flags & THREAD_FLAG_USPACE) {
 #ifdef CONFIG_UDEBUG
 		/* Generate udebug THREAD_E event */
 		udebug_thread_e_event();
-		
+
 		/*
 		 * This thread will not execute any code or system calls from
@@ -524,5 +506,5 @@
 {
 	ASSERT(THREAD);
-	
+
 	THREAD->nomigrate++;
 }
@@ -533,7 +515,6 @@
 	ASSERT(THREAD);
 	ASSERT(THREAD->nomigrate > 0);
-	
-	if (THREAD->nomigrate > 0)
-		THREAD->nomigrate--;
+
+	THREAD->nomigrate--;
 }
 
@@ -873,4 +854,5 @@
 	 * In case of failure, kernel_uarg will be deallocated in this function.
 	 * In case of success, kernel_uarg will be freed in uinit().
+	 *
 	 */
 	uspace_arg_t *kernel_uarg =
@@ -884,5 +866,5 @@
 	
 	thread_t *thread = thread_create(uinit, kernel_uarg, TASK,
-	    THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf);
+	    THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf, false);
 	if (thread) {
 		if (uspace_thread_id != NULL) {
Index: kernel/generic/src/synch/spinlock.c
===================================================================
--- kernel/generic/src/synch/spinlock.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/synch/spinlock.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -262,5 +262,5 @@
 	int rc = spinlock_trylock(&(lock->lock));
 	
-	ASSERT_IRQ_SPINLOCK((!rc) || (!lock->guard), lock);
+	ASSERT_IRQ_SPINLOCK(!rc || !lock->guard, lock);
 	return rc;
 }
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -97,5 +97,5 @@
 void sysinfo_init(void)
 {
-	sysinfo_item_slab = slab_cache_create("sysinfo_item_t",
+	sysinfo_item_slab = slab_cache_create("sysinfo_item_slab",
 	    sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
 	    sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
Index: kernel/generic/src/udebug/udebug.c
===================================================================
--- kernel/generic/src/udebug/udebug.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/udebug/udebug.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -410,7 +410,8 @@
 		
 		mutex_lock(&thread->udebug.lock);
+		unsigned int flags = thread->flags;
 		
 		/* Only process userspace threads. */
-		if (thread->uspace) {
+		if ((flags & THREAD_FLAG_USPACE) != 0) {
 			/* Prevent any further debug activity in thread. */
 			thread->udebug.active = false;
Index: kernel/generic/src/udebug/udebug_ops.c
===================================================================
--- kernel/generic/src/udebug/udebug_ops.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -95,5 +95,5 @@
 	
 	/* Verify that 'thread' is a userspace thread. */
-	if (!thread->uspace) {
+	if ((thread->flags & THREAD_FLAG_USPACE) == 0) {
 		/* It's not, deny its existence */
 		irq_spinlock_unlock(&thread->lock, true);
@@ -200,5 +200,5 @@
 		
 		mutex_lock(&thread->udebug.lock);
-		if (thread->uspace) {
+		if ((thread->flags & THREAD_FLAG_USPACE) != 0) {
 			thread->udebug.active = true;
 			mutex_unlock(&thread->udebug.lock);
@@ -393,9 +393,9 @@
 		
 		irq_spinlock_lock(&thread->lock, false);
-		bool uspace = thread->uspace;
+		int flags = thread->flags;
 		irq_spinlock_unlock(&thread->lock, false);
 		
 		/* Not interested in kernel threads. */
-		if (!uspace)
+		if ((flags & THREAD_FLAG_USPACE) == 0)
 			continue;
 		
Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/mm/falloc1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,31 +37,32 @@
 #include <align.h>
 
-#define MAX_FRAMES  1024U
+#define MAX_FRAMES  1024
 #define MAX_ORDER   8
 #define TEST_RUNS   2
 
-const char *test_falloc1(void)
-{
+const char *test_falloc1(void) {
+	uintptr_t *frames
+	    = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
+	int results[MAX_ORDER + 1];
+	
+	int i, order, run;
+	int allocated;
+	
 	if (TEST_RUNS < 2)
 		return "Test is compiled with TEST_RUNS < 2";
 	
-	uintptr_t *frames = (uintptr_t *)
-	    malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
 	if (frames == NULL)
 		return "Unable to allocate frames";
 	
-	unsigned int results[MAX_ORDER + 1];
-	for (unsigned int run = 0; run < TEST_RUNS; run++) {
-		for (unsigned int order = 0; order <= MAX_ORDER; order++) {
-			TPRINTF("Allocating %u frames blocks ... ", 1 << order);
+	for (run = 0; run < TEST_RUNS; run++) {
+		for (order = 0; order <= MAX_ORDER; order++) {
+			TPRINTF("Allocating %d frames blocks ... ", 1 << order);
 			
-			unsigned int allocated = 0;
-			for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
-				frames[allocated] = (uintptr_t)
-				    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+			allocated = 0;
+			for (i = 0; i < MAX_FRAMES >> order; i++) {
+				frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
 				
-				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) !=
-				    frames[allocated]) {
-					TPRINTF("Block at address %p (size %u) is not aligned\n",
+				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
+					TPRINTF("Block at address %p (size %dK) is not aligned\n",
 					    (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
 					return "Test failed";
@@ -86,5 +87,5 @@
 			TPRINTF("Deallocating ... ");
 			
-			for (unsigned int i = 0; i < allocated; i++)
+			for (i = 0; i < allocated; i++)
 				frame_free(KA2PA(frames[i]));
 			
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/mm/falloc2.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,5 @@
 #include <arch.h>
 
-#define MAX_FRAMES  256U
+#define MAX_FRAMES  256
 #define MAX_ORDER   8
 
@@ -51,11 +51,11 @@
 static void falloc(void *arg)
 {
+	int order, run, allocated, i;
 	uint8_t val = THREAD->tid % THREADS;
+	size_t k;
 	
-	void **frames = (void **)
-	    malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
+	void **frames =  (void **) malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
 	if (frames == NULL) {
-		TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-		    "Unable to allocate frames\n", THREAD->tid, CPU->id);
+		TPRINTF("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id);
 		atomic_inc(&thread_fail);
 		atomic_dec(&thread_count);
@@ -65,14 +65,11 @@
 	thread_detach(THREAD);
 	
-	for (unsigned int run = 0; run < THREAD_RUNS; run++) {
-		for (unsigned int order = 0; order <= MAX_ORDER; order++) {
-			TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-			    "Allocating %u frames blocks ... \n", THREAD->tid,
-			    CPU->id, 1 << order);
+	for (run = 0; run < THREAD_RUNS; run++) {
+		for (order = 0; order <= MAX_ORDER; order++) {
+			TPRINTF("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
 			
-			unsigned int allocated = 0;
-			for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
-				frames[allocated] =
-				    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+			allocated = 0;
+			for (i = 0; i < (MAX_FRAMES >> order); i++) {
+				frames[allocated] = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
 				if (frames[allocated]) {
 					memsetb(frames[allocated], FRAME_SIZE << order, val);
@@ -82,18 +79,12 @@
 			}
 			
-			TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-			    "%u blocks allocated.\n", THREAD->tid, CPU->id,
-			    allocated);
-			TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-			    "Deallocating ... \n", THREAD->tid, CPU->id);
+			TPRINTF("Thread #%" PRIu64 " (cpu%u): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
+			TPRINTF("Thread #%" PRIu64 " (cpu%u): Deallocating ... \n", THREAD->tid, CPU->id);
 			
-			for (unsigned int i = 0; i < allocated; i++) {
-				for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1);
-				    k++) {
+			for (i = 0; i < allocated; i++) {
+				for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) {
 					if (((uint8_t *) frames[i])[k] != val) {
-						TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-						    "Unexpected data (%c) in block %p offset %zu\n",
-						    THREAD->tid, CPU->id, ((char *) frames[i])[k],
-						    frames[i], k);
+						TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %zu\n",
+						    THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
 						atomic_inc(&thread_fail);
 						goto cleanup;
@@ -103,6 +94,5 @@
 			}
 			
-			TPRINTF("Thread #%" PRIu64 " (cpu%u): "
-			    "Finished run.\n", THREAD->tid, CPU->id);
+			TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
 		}
 	}
@@ -111,6 +101,5 @@
 	free(frames);
 	
-	TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
-	    THREAD->tid, CPU->id);
+	TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id);
 	atomic_dec(&thread_count);
 }
@@ -118,10 +107,11 @@
 const char *test_falloc2(void)
 {
+	unsigned int i;
+	
 	atomic_set(&thread_count, THREADS);
 	atomic_set(&thread_fail, 0);
 	
-	for (unsigned int i = 0; i < THREADS; i++) {
-		thread_t *thrd = thread_create(falloc, NULL, TASK,
-		    THREAD_FLAG_NONE, "falloc2");
+	for (i = 0; i < THREADS; i++) {
+		thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false);
 		if (!thrd) {
 			TPRINTF("Could not create thread %u\n", i);
@@ -132,6 +122,5 @@
 	
 	while (atomic_get(&thread_count) > 0) {
-		TPRINTF("Threads left: %" PRIua "\n",
-		    atomic_get(&thread_count));
+		TPRINTF("Threads left: %" PRIua "\n", atomic_get(&thread_count));
 		thread_sleep(1);
 	}
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/mm/slab1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -155,6 +155,6 @@
 	
 	semaphore_initialize(&thr_sem, 0);
-	for (i = 0; i < THREADS; i++) {
-		if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) {
+	for (i = 0; i < THREADS; i++) {  
+		if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, 0, "slabtest", false))) {
 			TPRINTF("Could not create thread %d\n", i);
 		} else
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/mm/slab2.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -52,6 +52,6 @@
 	void *olddata1 = NULL, *olddata2 = NULL;
 	
-	cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
-	cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0);
+	cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
+	cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
 	
 	TPRINTF("Allocating...");
@@ -210,6 +210,6 @@
 	thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
 	semaphore_initialize(&thr_sem,0);
-	for (i = 0; i < THREADS; i++) {
-		if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) {
+	for (i = 0; i < THREADS; i++) {  
+		if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {
 			TPRINTF("Could not create thread %d\n", i);
 		} else
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/synch/semaphore1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -93,6 +93,5 @@
 		for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
 			for (k = 0; k < i; k++) {
-				thrd = thread_create(consumer, NULL, TASK,
-				    THREAD_FLAG_NONE, "consumer");
+				thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
 				if (thrd)
 					thread_ready(thrd);
@@ -101,6 +100,5 @@
 			}
 			for (k = 0; k < (4 - i); k++) {
-				thrd = thread_create(producer, NULL, TASK,
-				    THREAD_FLAG_NONE, "producer");
+				thrd = thread_create(producer, NULL, TASK, 0, "producer", false);
 				if (thrd)
 					thread_ready(thrd);
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/synch/semaphore2.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -93,6 +93,5 @@
 	TPRINTF("Creating %" PRIu32 " consumers\n", k);
 	for (i = 0; i < k; i++) {
-		thrd = thread_create(consumer, NULL, TASK,
-		    THREAD_FLAG_NONE, "consumer");
+		thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
 		if (thrd)
 			thread_ready(thrd);
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ kernel/test/thread/thread1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -63,6 +63,5 @@
 	for (i = 0; i < THREADS; i++) {
 		thread_t *t;
-		if (!(t = thread_create(threadtest, NULL, TASK,
-		    THREAD_FLAG_NONE, "threadtest"))) {
+		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
 			TPRINTF("Could not create thread %d\n", i);
 			break;
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ tools/autotool.py	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -720,4 +720,10 @@
 			check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
 		
+		if (config['COMPILER'] == "suncc"):
+			common['CC'] = "suncc"
+			check_app([common['CC'], "-V"], "Sun Studio Compiler", "support is experimental")
+			check_gcc(None, "", common, PACKAGE_GCC)
+			check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
+		
 		if (config['COMPILER'] == "clang"):
 			common['CC'] = "clang"
Index: ols/dest_build.py
===================================================================
--- tools/dest_build.py	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,107 +1,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2012 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.
-#
-
-"""
-HelenOS out-of-source-tree build utility
-"""
-
-import sys
-import os
-import stat
-import errno
-import subprocess
-
-exclude_names = set(['.svn', '.bzr'])
-
-def duplicate_tree(src_path, dest_path, current):
-	"Duplicate source directory tree in the destination path"
-	
-	for name in os.listdir(os.path.join(src_path, current)):
-		if name in exclude_names:
-			next
-		
-		following = os.path.join(current, name)
-		src = os.path.join(src_path, following)
-		dest = os.path.join(dest_path, following)
-		dest_parent = os.path.join(dest_path, current)
-		dest_stat = os.stat(src)
-		
-		# Create shadow directories
-		if stat.S_ISDIR(dest_stat.st_mode):
-			if not os.path.exists(dest):
-				os.mkdir(dest)
-			
-			if not os.path.isdir(dest):
-				raise IOError(errno.ENOTDIR, "Destination path exists, but is not a directory", dest)
-			
-			duplicate_tree(src_path, dest_path, following)
-		else:
-			# Compute the relative path from destination to source
-			relative = os.path.relpath(src, dest_parent)
-			
-			# Create symlink
-			if not os.path.exists(dest):
-				os.symlink(relative, dest)
-
-def usage(prname):
-	"Print usage syntax"
-	print(prname + " <SRC_PATH> <DEST_PATH> [MAKE ARGS...]")
-
-def main():
-	if len(sys.argv) < 3:
-		usage(sys.argv[0])
-		return 1
-	
-	# Source tree path
-	src_path = os.path.abspath(sys.argv[1])
-	if not os.path.isdir(src_path):
-		print("<SRC_PATH> must be a directory")
-		return 2
-	
-	# Destination tree path
-	dest_path = os.path.abspath(sys.argv[2])
-	if not os.path.exists(dest_path):
-		os.mkdir(dest_path)
-	
-	if not os.path.isdir(dest_path):
-		print("<DEST_PATH> must be a directory")
-		return 3
-	
-	# Duplicate source directory tree
-	duplicate_tree(src_path, dest_path, "")
-	
-	# Run the build from the destination tree
-	os.chdir(dest_path)
-	args = ["make"]
-	args.extend(sys.argv[3:])
-	
-	return subprocess.Popen(args).wait()
-
-if __name__ == '__main__':
-	sys.exit(main())
Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ tools/toolchain.sh	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -55,5 +55,5 @@
 BINUTILS_VERSION="2.22"
 BINUTILS_RELEASE=""
-GCC_VERSION="4.7.1"
+GCC_VERSION="4.7.0"
 GDB_VERSION="7.4"
 
@@ -149,6 +149,5 @@
 	echo " sparc64    SPARC V9"
 	echo " all        build all targets"
-	echo " parallel   same as 'all', but all in parallel"
-	echo " 2-way      same as 'all', but 2-way parallel"
+	echo " parallel   same as 'all', but in parallel"
 	echo
 	echo "The toolchain will be installed to the directory specified by"
@@ -274,5 +273,5 @@
 	
 	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5"
-	download_fetch "${GCC_SOURCE}" "${GCC}" "933e6f15f51c031060af64a9e14149ff"
+	download_fetch "${GCC_SOURCE}" "${GCC}" "2a0f1d99fda235c29d40b561f81d9a77"
 	download_fetch "${GDB_SOURCE}" "${GDB}" "95a9a8305fed4d30a30a6dc28ff9d060"
 }
@@ -319,5 +318,5 @@
 	
 	change_title "binutils: configure (${PLATFORM})"
-	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls --disable-werror
+	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls
 	check_error $? "Error configuring binutils."
 	
@@ -331,5 +330,5 @@
 	
 	change_title "GCC: configure (${PLATFORM})"
-	"${GCCDIR}/configure" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c,objc,c++,obj-c++ --disable-multilib --disable-libgcj --without-headers --disable-shared --enable-lto --disable-werror
+	"${GCCDIR}/configure" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c,objc,c++,obj-c++ --disable-multilib --disable-libgcj --without-headers --disable-shared --enable-lto
 	check_error $? "Error configuring GCC."
 	
@@ -432,26 +431,4 @@
 		wait
 		;;
-	"2-way")
-		prepare
-		build_target "amd64" "amd64-linux-gnu" &
-		build_target "arm32" "arm-linux-gnueabi" &
-		wait
-		
-		build_target "ia32" "i686-pc-linux-gnu" &
-		build_target "ia64" "ia64-pc-linux-gnu" &
-		wait
-		
-		build_target "mips32" "mipsel-linux-gnu" &
-		build_target "mips32eb" "mips-linux-gnu" &
-		wait
-		
-		build_target "mips64" "mips64el-linux-gnu" &
-		build_target "ppc32" "ppc-linux-gnu" &
-		wait
-		
-		build_target "ppc64" "ppc64-linux-gnu" &
-		build_target "sparc64" "sparc64-linux-gnu" &
-		wait
-		;;
 	*)
 		show_usage
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/Makefile	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -138,9 +138,4 @@
 endif
 
-ifeq ($(CONFIG_MSIM),y)
-DIRS += \
-	app/msim
-endif
-
 ## Platform-specific hardware support
 #
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/Makefile.common	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -206,4 +206,5 @@
 	GCC_CFLAGS += -g
 	ICC_CFLAGS += -g
+	SUNCC_CFLAGS += -g
 	CLANG_CFLAGS += -g
 endif
Index: uspace/app/devctl/devctl.c
===================================================================
--- uspace/app/devctl/devctl.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/devctl/devctl.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -44,9 +44,7 @@
 #define MAX_NAME_LENGTH 1024
 
-char name[MAX_NAME_LENGTH];
-char drv_name[MAX_NAME_LENGTH];
-
 static int fun_subtree_print(devman_handle_t funh, int lvl)
 {
+	char name[MAX_NAME_LENGTH];
 	devman_handle_t devh;
 	devman_handle_t *cfuns;
@@ -59,18 +57,13 @@
 
 	rc = devman_fun_get_name(funh, name, MAX_NAME_LENGTH);
-	if (rc != EOK)
-		return ELIMIT;
+	if (rc != EOK) {
+		str_cpy(name, MAX_NAME_LENGTH, "unknown");
+		return ENOMEM;
+	}
 
 	if (name[0] == '\0')
 		str_cpy(name, MAX_NAME_LENGTH, "/");
 
-	rc = devman_fun_get_driver_name(funh, drv_name, MAX_NAME_LENGTH);
-	if (rc != EOK && rc != EINVAL)
-		return ELIMIT;
-
-	if (rc == EINVAL)
-		printf("%s\n", name);
-	else
-		printf("%s : %s\n", name, drv_name);
+	printf("%s (%" PRIun ")\n", name, funh);
 
 	rc = devman_fun_get_child(funh, &devh);
Index: uspace/app/killall/killall.c
===================================================================
--- uspace/app/killall/killall.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/killall/killall.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,5 +36,4 @@
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <task.h>
 #include <stats.h>
Index: uspace/app/loc/loc.c
===================================================================
--- uspace/app/loc/loc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/loc/loc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -48,9 +48,8 @@
 	size_t svc_cnt;
 	char *svc_name;
-	char *server_name;
 	int rc;
 	size_t j;
 
-	printf("%s:\n", cat_name);
+	printf("%s (%" PRIun "):\n", cat_name, cat_id);
 
 	rc = loc_category_get_svcs(cat_id, &svc_ids, &svc_cnt);
@@ -68,20 +67,6 @@
 			continue;
 		}
-
-		rc = loc_service_get_server_name(svc_ids[j], &server_name);
-		if (rc != EOK && rc != EINVAL) {
-			free(svc_name);
-			printf(NAME ": Unknown service name (SID %"
-			    PRIun ").\n", svc_ids[j]);
-			continue;
-		}
-
-		if (rc == EOK)
-			printf("\t%s : %s\n", svc_name, server_name);
-		else
-			printf("\t%s\n", svc_name);
-	
+		printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]);
 		free(svc_name);
-		free(server_name);
 	}
 
Index: pace/app/msim/Makefile
===================================================================
--- uspace/app/msim/Makefile	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,99 +1,0 @@
-#
-# Copyright (c) 2012 Vojtech Horky
-# 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.
-#
-
-USPACE_PREFIX = ../..
-BINARY = msim
-
-MSIM_VERSION = 1.3.8.1
-MSIM_DIST = msim-$(MSIM_VERSION)
-MSIM_TARBALL = $(MSIM_DIST).tar.bz2
-MSIM_MIRROR = http://d3s.mff.cuni.cz/~holub/sw/msim/
-
-MSIM_HELENOS_MAKEFILE = Makefile.msim.src
-MSIM_HELENOS_PLATFORM_FILES = misc.c input.c
-MSIM_HELENOS_ARCH_DIR = arch/helenos
-MSIM_PATCHED_FILES = \
-	$(MSIM_DIST)/config.h \
-	$(MSIM_DIST)/src/$(MSIM_HELENOS_MAKEFILE) \
-	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/helenos.h \
-	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/misc.c \
-	$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/input.c
-
-MSIM_EXTRA_SOURCES := $(addprefix $(MSIM_HELENOS_ARCH_DIR)/,$(MSIM_HELENOS_PLATFORM_FILES))
-
-CP = /bin/cp -f
-
-all: $(BINARY)
-
-.PHONY: all clean unpack-tarball
-
-clean:
-	rm -rf msim Makefile.depend* *.map *.disasm $(MSIM_TARBALL) $(MSIM_DIST)
-
-$(BINARY): $(MSIM_DIST)/src/msim
-	$(CP) $< $@
-
-# Run make in MSIM src directory
-$(MSIM_DIST)/src/msim: $(MSIM_PATCHED_FILES) $(MSIM_DIST)/src/Makefile.sources Makefile 
-	cd $(MSIM_DIST)/src; make -f $(MSIM_HELENOS_MAKEFILE) USPACE_PREFIX=../../$(USPACE_PREFIX)
-	
-# Copy HelenOS specific files
-$(MSIM_DIST)/config.h: config.h.msim | unpack-tarball
-	$(CP) $< $@
-
-$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/helenos.h: arch_helenos/helenos.h | unpack-tarball
-	$(CP) $< $@
-
-$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/misc.c: arch_helenos/misc.c | unpack-tarball
-	$(CP) $< $@
-
-$(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)/input.c: arch_helenos/input.c | unpack-tarball
-	$(CP) $< $@
-
-$(MSIM_DIST)/src/$(MSIM_HELENOS_MAKEFILE): $(MSIM_HELENOS_MAKEFILE) | unpack-tarball
-	$(CP) $< $@
-
-# Extract list of sources, remove POSIX/Linux specific
-$(MSIM_DIST)/src/Makefile.sources: | unpack-tarball
-	cd $(MSIM_DIST)/src; ( \
-		echo 'all__:'; \
-		echo -e '\t@echo SOURCES = $$(SOURCES)'; cat Makefile.in \
-	) | make -f - | grep 'SOURCES' >Makefile.sources
-	sed \
-		-e 's:io/input.c:$(MSIM_EXTRA_SOURCES):' \
-		-e 's:debug/gdb.c::' \
-		-e 's:arch/posix/stdin.c::' \
-		-i $(MSIM_DIST)/src/Makefile.sources
-
-# Download tarball
-$(MSIM_TARBALL):
-	wget "$(MSIM_MIRROR)$(MSIM_TARBALL)" -O $(MSIM_TARBALL)
-
-unpack-tarball: $(MSIM_TARBALL)
-	tar xjf $(MSIM_TARBALL)
-	mkdir -p $(MSIM_DIST)/src/$(MSIM_HELENOS_ARCH_DIR)
Index: pace/app/msim/Makefile.msim.src
===================================================================
--- uspace/app/msim/Makefile.msim.src	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#
-# Copyright (c) 2012 Vojtech Horky
-# 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.
-#
-
-
-BINARY = msim
-LIBS = $(LIBCLUI_PREFIX)/libclui.a
-POSIX_COMPAT = y
-# Needed because MSIM is not that strict as HelenOS
-EXTRA_CFLAGS = -Wno-error -I$(LIBCLUI_PREFIX)
-
-include Makefile.sources
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/app/msim/arch_helenos/helenos.h
===================================================================
--- uspace/app/msim/arch_helenos/helenos.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 msim
- * @{
- */
-
-#ifndef MSIM_HELENOS_H_
-#define MSIM_HELENOS_H_
-
-char *helenos_input_get_next_command(void);
-void helenos_dprinter_init(void);
-
-#endif
-
-/**
- * @}
- */
-
Index: pace/app/msim/arch_helenos/input.c
===================================================================
--- uspace/app/msim/arch_helenos/input.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,105 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 msim
- * @{
- */
-/** @file HelenOS specific functions for MSIM simulator.
- */
-#include "../../io/input.h"
-#include "../../io/output.h"
-#include "../../fault.h"
-#include "helenos.h"
-#include <tinput.h>
-#include <errno.h>
-
-static tinput_t *input_prompt;
-
-/** Terminal and readline initialization
- *
- */
-void input_init(void)
-{
-	input_prompt = tinput_new();
-	if (input_prompt == NULL) {
-		die(1, "Failed to intialize input.");
-	}
-	helenos_dprinter_init();
-}
-
-void input_inter(void)
-{
-}
-
-void input_shadow( void)
-{
-}
-
-void input_back( void)
-{
-}
-
-char *helenos_input_get_next_command(void)
-{
-	tinput_set_prompt(input_prompt, "[msim] ");
-
-	char *commline = NULL;
-	int rc = tinput_read(input_prompt, &commline);
-
-	if (rc == ENOENT) {
-		rc = asprintf(&commline, "quit");
-		mprintf("Quit\n");
-		if (rc != EOK) {
-			exit(1);
-		}
-	}
-
-	/* On error, it remains NULL. */
-	return commline;
-}
-
-
-bool stdin_poll(char *key)
-{
-	kbd_event_t ev;
-	suseconds_t timeout = 0;
-	errno = EOK;
-	console_flush(input_prompt->console);
-	bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
-	if (!has_input) {
-		return false;
-	}
-
-	if (ev.type != KEY_PRESS)
-		return false;
-
-	*key = ev.c;
-
-	return true;
-}
-
Index: pace/app/msim/arch_helenos/misc.c
===================================================================
--- uspace/app/msim/arch_helenos/misc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,149 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 msim
- * @{
- */
-/** @file HelenOS specific functions for MSIM simulator.
- */
-#include "../../io/input.h"
-#include "../../io/output.h"
-#include "../../device/dprinter.h"
-#include "../../debug/gdb.h"
-#include "../../cmd.h"
-#include "../../fault.h"
-#include "../../device/machine.h"
-#include "helenos.h"
-#include <str.h>
-#include <malloc.h>
-#include <ctype.h>
-#include <stdio.h>
-
-/* Define when the dprinter device shall try to filter
- * out ANSI escape sequences.
- */
-#define IGNORE_ANSI_ESCAPE_SEQUENCES
-/* Define when you want the ANSI escape sequences to be dumped as
- * hex numbers.
- */
-// #define DUMP_ANSI_ESCAPE_SEQUENCES
-
-void interactive_control(void)
-{
-	tobreak = false;
-
-	if (reenter) {
-		mprintf("\n");
-		reenter = false;
-	}
-
-	stepping = 0;
-
-	while (interactive) {
-		char *commline = helenos_input_get_next_command();
-		if (commline == NULL) {
-			mprintf("Quit\n");
-			input_back();
-			exit(1);
-		}
-
-		/* Check for empty input. */
-		if (str_cmp(commline, "") == 0) {
-			interpret("step");
-		} else {
-			interpret(commline);
-		}
-
-		free(commline);
-	}
-}
-
-bool gdb_remote_init(void)
-{
-	return false;
-}
-
-void gdb_session(void)
-{
-}
-
-void gdb_handle_event(gdb_event_t event)
-{
-}
-
-
-static void (*original_printer_write)(cpu_t *, device_s *, ptr_t, uint32_t);
-static void helenos_printer_write(cpu_t *cpu, device_s *dev, ptr_t addr, uint32_t val)
-{
-#ifdef IGNORE_ANSI_ESCAPE_SEQUENCES
-	static bool inside_ansi_escape = false;
-	static bool just_ended_ansi_escape = false;
-
-	if (inside_ansi_escape) {
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-		fprintf(stderr, "%02" PRIx32 "'%c' ", val, val >= 32 ? val : '?');
-#endif
-		if (isalpha((int) val)) {
-			just_ended_ansi_escape = true;
-			inside_ansi_escape = false;
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-			fprintf(stderr, " [END]\n");
-#endif
-		}
-
-		return;
-	}
-
-	if (val == 0x1B) {
-		inside_ansi_escape = true;
-
-		if (!just_ended_ansi_escape) {
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-			fprintf(stderr, "\n");
-#endif
-		}
-#ifdef DUMP_ANSI_ESCAPE_SEQUENCES
-		fprintf(stderr, "ESC sequence: ");
-#endif
-
-		return;
-	}
-
-	just_ended_ansi_escape = false;
-#endif
-
-	(*original_printer_write)(cpu, dev, addr, val);
-}
-
-void helenos_dprinter_init(void)
-{
-	original_printer_write = dprinter.write;
-	dprinter.write = helenos_printer_write;
-}
-
-
Index: pace/app/msim/config.h.msim
===================================================================
--- uspace/app/msim/config.h.msim	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,108 +1,0 @@
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define to 1 if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the <getopt.h> header file. */
-#define HAVE_GETOPT_H 1
-
-/* Define to 1 if you have the `getopt_long' function. */
-#define HAVE_GETOPT_LONG 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `readline' library (-lreadline). */
-#define HAVE_LIBREADLINE 1
-
-/* Define to 1 if you have the `wsock32' library (-lwsock32). */
-/* #undef HAVE_LIBWSOCK32 */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <readline/history.h> header file. */
-#define HAVE_READLINE_HISTORY_H 1
-
-/* Define to 1 if you have the <readline/readline.h> header file. */
-#define HAVE_READLINE_READLINE_H 1
-
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the <stdbool.h> header file. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <time.h> header file. */
-#define HAVE_TIME_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Name of package */
-#define PACKAGE "msim"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.3.8.1"
-
-/* Define to 1 if your processor stores words with the most significant byte
-   first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
Index: uspace/app/nettest1/nettest1.c
===================================================================
--- uspace/app/nettest1/nettest1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/nettest1/nettest1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,4 @@
 #include <malloc.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <str.h>
 #include <task.h>
Index: uspace/app/nettest2/nettest2.c
===================================================================
--- uspace/app/nettest2/nettest2.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/nettest2/nettest2.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,4 @@
 #include <malloc.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <str.h>
 #include <task.h>
Index: uspace/app/sbi/src/mytypes.h
===================================================================
--- uspace/app/sbi/src/mytypes.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/sbi/src/mytypes.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -51,6 +51,4 @@
 /** Error return codes. */
 #include <errno.h>
-/** We need NULL defined. */
-#include <unistd.h>
 #define EOK 0
 
Index: uspace/app/sysinfo/sysinfo.c
===================================================================
--- uspace/app/sysinfo/sysinfo.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/sysinfo/sysinfo.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,5 +36,4 @@
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <sysinfo.h>
 #include <malloc.h>
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -48,7 +48,6 @@
 #include "../../tester.h"
 
-#define DEVICE_PATH_NORMAL  "/loc/devices/\\virt\\null\\a"
-
-#define BUFFER_SIZE  64
+#define DEVICE_PATH_NORMAL "/loc/devices/\\virt\\null\\a"
+#define BUFFER_SIZE 64
 
 static const char *test_virtchar1_internal(const char *path)
@@ -66,5 +65,5 @@
 	
 	TPRINTF("   ...file handle %d\n", fd);
-	
+
 	TPRINTF(" Asking for session...\n");
 	async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
@@ -97,9 +96,12 @@
 
 const char *test_virtchar1(void)
-{
-	const char *res = test_virtchar1_internal(DEVICE_PATH_NORMAL);
-	if (res != NULL)
+{;
+	const char *res;
+
+	res = test_virtchar1_internal(DEVICE_PATH_NORMAL);
+	if (res != NULL) {
 		return res;
-	
+	}
+
 	return NULL;
 }
Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/tester/mm/common.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -342,7 +342,7 @@
 	link_initialize(&area->link);
 	
-	area->addr = as_area_create(AS_AREA_ANY, size,
+	area->addr = as_area_create((void *) -1, size,
 	    AS_AREA_WRITE | AS_AREA_READ);
-	if (area->addr == AS_MAP_FAILED) {
+	if (area->addr == (void *) -1) {
 		free(area);
 		check_consistency("map_area (a)");
Index: uspace/app/tester/mm/mapping1.c
===================================================================
--- uspace/app/tester/mm/mapping1.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/tester/mm/mapping1.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -42,7 +42,7 @@
 	TPRINTF("Creating AS area...\n");
 	
-	void *result = as_area_create(AS_AREA_ANY, size,
+	void *result = as_area_create((void *) -1, size,
 	    AS_AREA_READ | AS_AREA_WRITE);
-	if (result == AS_MAP_FAILED)
+	if (result == (void *) -1)
 		return NULL;
 	
Index: uspace/app/trace/proto.h
===================================================================
--- uspace/app/trace/proto.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/trace/proto.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -44,10 +44,10 @@
 typedef struct {
 	const char *name;
-	
+
 	int argc;
 	val_type_t arg_type[OPER_MAX_ARGS];
-	
+
 	val_type_t rv_type;
-	
+
 	int respc;
 	val_type_t resp_type[OPER_MAX_ARGS];
@@ -57,5 +57,5 @@
 	/** Protocol name */
 	const char *name;
-	
+
 	/** Maps method number to operation */
 	hash_table_t method_oper;
@@ -65,16 +65,18 @@
 extern hash_table_t srv_proto;
 
-extern void proto_init(void);
-extern void proto_cleanup(void);
+void proto_init(void);
+void proto_cleanup(void);
 
-extern void proto_register(int, proto_t *);
-extern proto_t *proto_get_by_srv(int);
-extern proto_t *proto_new(const char *);
-extern void proto_delete(proto_t *);
-extern void proto_add_oper(proto_t *, int, oper_t *);
-extern oper_t *proto_get_oper(proto_t *, int);
+void proto_register(int srv, proto_t *proto);
+proto_t *proto_get_by_srv(int srv);
+proto_t *proto_new(const char *name);
+void proto_delete(proto_t *proto);
+void proto_add_oper(proto_t *proto, int method, oper_t *oper);
+oper_t *proto_get_oper(proto_t *proto, int method);
 
-extern oper_t *oper_new(const char *, int, val_type_t *, val_type_t, int,
-    val_type_t *);
+oper_t *oper_new(const char *name, int argc, val_type_t *arg_types,
+    val_type_t rv_type, int respc, val_type_t *resp_types);
+
+
 
 #endif
Index: uspace/app/websrv/websrv.c
===================================================================
--- uspace/app/websrv/websrv.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/app/websrv/websrv.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,5 +36,4 @@
 #include <bool.h>
 #include <errno.h>
-#include <assert.h>
 #include <stdio.h>
 #include <sys/types.h>
Index: uspace/drv/bus/isa/isa.c
===================================================================
--- uspace/drv/bus/isa/isa.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/isa/isa.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -201,8 +201,6 @@
 
 	isa_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(isa_fun_t));
-	if (fun == NULL) {
-		ddf_fun_destroy(fnode);
+	if (fun == NULL)
 		return NULL;
-	}
 
 	fibril_mutex_initialize(&fun->mutex);
@@ -554,6 +552,6 @@
 
 	isa_fun_t *fun = isa_fun_create(isa, fun_name);
-	free(fun_name);
 	if (fun == NULL) {
+		free(fun_name);
 		return NULL;
 	}
Index: uspace/drv/bus/usb/ehci/res.c
===================================================================
--- uspace/drv/bus/usb/ehci/res.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/usb/ehci/res.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -109,5 +109,5 @@
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Calls the PCI driver with a request to enable interrupts
  *
@@ -127,5 +127,5 @@
 	return enabled ? EOK : EIO;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Implements BIOS hands-off routine as described in EHCI spec
  *
Index: uspace/drv/bus/usb/ohci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/ohci/utils/malloc32.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/usb/ohci/utils/malloc32.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,5 +37,4 @@
 #include <assert.h>
 #include <malloc.h>
-#include <unistd.h>
 #include <errno.h>
 #include <mem.h>
Index: uspace/drv/bus/usb/uhci/res.c
===================================================================
--- uspace/drv/bus/usb/uhci/res.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/usb/uhci/res.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -86,5 +86,5 @@
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Call the PCI driver with a request to enable interrupts
  *
@@ -105,5 +105,5 @@
 	return enabled ? EOK : EIO;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Call the PCI driver with a request to clear legacy support register
  *
Index: uspace/drv/bus/usb/uhci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,5 +36,4 @@
 
 #include <assert.h>
-#include <unistd.h>
 #include <errno.h>
 #include <malloc.h>
@@ -99,7 +98,7 @@
 static inline void * get_page(void)
 {
-	void *address = as_area_create(AS_AREA_ANY, UHCI_REQUIRED_PAGE_SIZE,
+	void *address = as_area_create((void *) -1, UHCI_REQUIRED_PAGE_SIZE,
 	    AS_AREA_READ | AS_AREA_WRITE);
-	if (address == AS_MAP_FAILED)
+	if (address == (void *) -1)
 		return NULL;
 	
Index: uspace/drv/bus/usb/usbmast/main.c
===================================================================
--- uspace/drv/bus/usb/usbmast/main.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/drv/bus/usb/usbmast/main.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -302,5 +302,5 @@
 	
 	(void) async_share_out_finalize(callid, &comm_buf);
-	if (comm_buf == AS_MAP_FAILED) {
+	if (comm_buf == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/lib/c/arch/ia64/include/fibril.h
===================================================================
--- uspace/lib/c/arch/ia64/include/fibril.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/arch/ia64/include/fibril.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -49,6 +49,8 @@
 #define PFM_MASK  (~0x3fffffffff)
 
+#define PSTHREAD_INITIAL_STACK_PAGES_NO  2
+
 /* Stack is divided into two equal parts (for memory stack and register stack). */
-#define FIBRIL_INITIAL_STACK_DIVISION  2
+#define PSTHREAD_INITIAL_STACK_DIVISION  2
 
 #define context_set(c, _pc, stack, size, tls) \
@@ -56,8 +58,8 @@
 		(c)->pc = (uint64_t) _pc; \
 		(c)->bsp = ((uint64_t) stack) + \
-		    size / FIBRIL_INITIAL_STACK_DIVISION; \
+		    size / PSTHREAD_INITIAL_STACK_DIVISION; \
 		(c)->ar_pfs &= PFM_MASK; \
 		(c)->sp = ((uint64_t) stack) + \
-		    ALIGN_UP((size / FIBRIL_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - \
+		    ALIGN_UP((size / PSTHREAD_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - \
 		    SP_DELTA; \
 		(c)->tp = (uint64_t) tls; \
Index: uspace/lib/c/arch/ia64/include/thread.h
===================================================================
--- uspace/lib/c/arch/ia64/include/thread.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/arch/ia64/include/thread.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcia64
+/** @addtogroup libcia64	
  * @{
  */
@@ -36,4 +36,6 @@
 #define LIBC_ia64_THREAD_H_
 
+#define THREAD_INITIAL_STACK_PAGES_NO 2
+
 #endif
 
Index: uspace/lib/c/generic/as.c
===================================================================
--- uspace/lib/c/generic/as.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/as.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -46,11 +46,11 @@
  *
  * @param base  Starting virtual address of the area.
- *              If set to AS_AREA_ANY ((void *) -1),
- *              the kernel finds a mappable area.
+ *              If set to (void *) -1, the kernel finds
+ *              a mappable area.
  * @param size  Size of the area.
  * @param flags Flags describing type of the area.
  *
  * @return Starting virtual address of the created area on success.
- * @return AS_MAP_FAILED ((void *) -1) otherwise.
+ * @return (void *) -1 otherwise.
  *
  */
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/async.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -1388,10 +1388,8 @@
 
 	futex_down(&async_futex);
-	if (msg->done) {
+	if (msg->done)
 		amsg_destroy(msg);
-	} else {
-		msg->dataptr = NULL;
+	else 
 		msg->forget = true;
-	}
 	futex_up(&async_futex);
 }
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/devman.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -430,7 +430,6 @@
 	async_wait_for(req, &retval);
 	
-	if (retval != EOK) {
-		return retval;
-	}
+	if (retval != EOK)
+		return retval;
 	
 	act_size = IPC_GET_ARG2(dreply);
@@ -450,10 +449,4 @@
 {
 	return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,
-	    buf_size);
-}
-
-int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size)
-{
-	return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,
 	    buf_size);
 }
Index: uspace/lib/c/generic/elf/elf_load.c
===================================================================
--- uspace/lib/c/generic/elf/elf_load.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/elf/elf_load.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -366,5 +366,5 @@
 	a = as_area_create((uint8_t *) base + bias, mem_sz,
 	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
-	if (a == AS_MAP_FAILED) {
+	if (a == (void *) -1) {
 		DPRINTF("memory mapping failed (0x%x, %d)\n",
 		    base + bias, mem_sz);
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/fibril.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -286,20 +286,4 @@
 }
 
-/** Delete a fibril that has never run.
- *
- * Free resources of a fibril that has been created with fibril_create()
- * but never readied using fibril_add_ready().
- *
- * @param fid Pointer to the fibril structure of the fibril to be
- *            added.
- */
-void fibril_destroy(fid_t fid)
-{
-	fibril_t *fibril = (fibril_t *) fid;
-	
-	free(fibril->stack);
-	fibril_teardown(fibril);
-}
-
 /** Add a fibril to the ready list.
  *
Index: uspace/lib/c/generic/inet.c
===================================================================
--- uspace/lib/c/generic/inet.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/inet.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -44,25 +44,29 @@
 {
 	async_exch_t *exch = async_exchange_begin(inet_sess);
-	
+
 	ipc_call_t answer;
 	aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer);
 	int rc = async_connect_to_me(exch, 0, 0, 0, inet_cb_conn, NULL);
 	async_exchange_end(exch);
-	
+
 	if (rc != EOK)
 		return rc;
-	
+
 	sysarg_t retval;
 	async_wait_for(req, &retval);
-	
-	return retval;
+	if (retval != EOK)
+		return retval;
+
+	return EOK;
 }
 
 static int inet_set_proto(uint8_t protocol)
 {
+	int rc;
+
 	async_exch_t *exch = async_exchange_begin(inet_sess);
-	int rc = async_req_1_0(exch, INET_SET_PROTO, protocol);
+	rc = async_req_1_0(exch, INET_SET_PROTO, protocol);
 	async_exchange_end(exch);
-	
+
 	return rc;
 }
@@ -76,15 +80,15 @@
 	assert(inet_ev_ops == NULL);
 	assert(inet_protocol == 0);
-	
+
 	rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc,
 	    IPC_FLAG_BLOCKING);
 	if (rc != EOK)
 		return ENOENT;
-	
+
 	inet_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc,
 	    IPC_FLAG_BLOCKING);
 	if (inet_sess == NULL)
 		return ENOENT;
-	
+
 	if (inet_set_proto(protocol) != EOK) {
 		async_hangup(inet_sess);
@@ -92,5 +96,5 @@
 		return EIO;
 	}
-	
+
 	if (inet_callback_create() != EOK) {
 		async_hangup(inet_sess);
@@ -98,5 +102,5 @@
 		return EIO;
 	}
-	
+
 	inet_protocol = protocol;
 	inet_ev_ops = ev_ops;
Index: uspace/lib/c/generic/inetcfg.c
===================================================================
--- uspace/lib/c/generic/inetcfg.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/inetcfg.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -119,15 +119,15 @@
 
 	assert(inetcfg_sess == NULL);
-	
+
 	rc = loc_service_get_id(SERVICE_NAME_INETCFG, &inet_svc,
 	    IPC_FLAG_BLOCKING);
 	if (rc != EOK)
 		return ENOENT;
-	
+
 	inetcfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc,
 	    IPC_FLAG_BLOCKING);
 	if (inetcfg_sess == NULL)
 		return ENOENT;
-	
+
 	return EOK;
 }
Index: uspace/lib/c/generic/inetping.c
===================================================================
--- uspace/lib/c/generic/inetping.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/inetping.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -49,22 +49,22 @@
 
 	assert(inetping_sess == NULL);
-	
+
 	inetping_ev_ops = ev_ops;
-	
+
 	rc = loc_service_get_id(SERVICE_NAME_INETPING, &inetping_svc,
 	    IPC_FLAG_BLOCKING);
 	if (rc != EOK)
 		return ENOENT;
-	
+
 	inetping_sess = loc_service_connect(EXCHANGE_SERIALIZE, inetping_svc,
 	    IPC_FLAG_BLOCKING);
 	if (inetping_sess == NULL)
 		return ENOENT;
-	
+
 	async_exch_t *exch = async_exchange_begin(inetping_sess);
 
 	rc = async_connect_to_me(exch, 0, 0, 0, inetping_cb_conn, NULL);
 	async_exchange_end(exch);
-	
+
 	if (rc != EOK) {
 		async_hangup(inetping_sess);
@@ -72,5 +72,5 @@
 		return rc;
 	}
-	
+
 	return EOK;
 }
Index: uspace/lib/c/generic/iplink.c
===================================================================
--- uspace/lib/c/generic/iplink.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/iplink.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -49,26 +49,29 @@
     iplink_t **riplink)
 {
-	iplink_t *iplink = calloc(1, sizeof(iplink_t));
+	iplink_t *iplink = NULL;
+	int rc;
+
+	iplink = calloc(1, sizeof(iplink_t));
 	if (iplink == NULL)
 		return ENOMEM;
-	
+
 	iplink->sess = sess;
 	iplink->ev_ops = ev_ops;
-	
+
 	async_exch_t *exch = async_exchange_begin(sess);
-	
-	int rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);
+
+	rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);
 	async_exchange_end(exch);
-	
+
 	if (rc != EOK)
 		goto error;
-	
+
 	*riplink = iplink;
 	return EOK;
-	
+
 error:
 	if (iplink != NULL)
 		free(iplink);
-	
+
 	return rc;
 }
Index: uspace/lib/c/generic/loc.c
===================================================================
--- uspace/lib/c/generic/loc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/loc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -450,18 +450,4 @@
 }
 
-/** Get service server name.
- *
- * Provided ID of a service, return the name of its server.
- *
- * @param svc_id	Service ID
- * @param name		Place to store pointer to new string. Caller should
- *			free it using free().
- * @return		EOK on success or negative error code
- */
-int loc_service_get_server_name(service_id_t svc_id, char **name)
-{
-	return loc_get_name_internal(LOC_SERVICE_GET_SERVER_NAME, svc_id, name);
-}
-
 int loc_namespace_get_id(const char *name, service_id_t *handle,
     unsigned int flags)
Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/malloc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -285,7 +285,7 @@
 	/* Align the heap area size on page boundary */
 	size_t asize = ALIGN_UP(size, PAGE_SIZE);
-	void *astart = as_area_create(AS_AREA_ANY, asize,
+	void *astart = as_area_create((void *) -1, asize,
 	    AS_AREA_WRITE | AS_AREA_READ);
-	if (astart == AS_MAP_FAILED)
+	if (astart == (void *) -1)
 		return false;
 	
Index: uspace/lib/c/generic/mman.c
===================================================================
--- uspace/lib/c/generic/mman.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/mman.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -42,5 +42,5 @@
 {
 	if (!start)
-		start = AS_AREA_ANY;
+		start = (void *) -1;
 	
 //	if (!((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
Index: uspace/lib/c/generic/net/socket_client.c
===================================================================
--- uspace/lib/c/generic/net/socket_client.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/net/socket_client.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -283,8 +283,9 @@
 static async_sess_t *socket_get_tcp_sess(void)
 {
-	if (socket_globals.tcp_sess == NULL)
+	if (socket_globals.tcp_sess == NULL) {
 		socket_globals.tcp_sess = service_bind(SERVICE_TCP,
 		    0, 0, SERVICE_TCP, socket_connection);
-	
+	}
+
 	return socket_globals.tcp_sess;
 }
@@ -299,8 +300,9 @@
 static async_sess_t *socket_get_udp_sess(void)
 {
-	if (socket_globals.udp_sess == NULL)
+	if (socket_globals.udp_sess == NULL) {
 		socket_globals.udp_sess = service_bind(SERVICE_UDP,
 		    0, 0, SERVICE_UDP, socket_connection);
-	
+	}
+
 	return socket_globals.udp_sess;
 }
Index: uspace/lib/c/generic/stacktrace.c
===================================================================
--- uspace/lib/c/generic/stacktrace.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/stacktrace.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -38,5 +38,4 @@
 #include <sys/types.h>
 #include <errno.h>
-#include <unistd.h>
 
 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
Index: uspace/lib/c/generic/stats.c
===================================================================
--- uspace/lib/c/generic/stats.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/stats.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,5 +40,4 @@
 #include <inttypes.h>
 #include <malloc.h>
-#include <unistd.h>
 
 #define SYSINFO_STATS_MAX_PATH  64
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/sysinfo.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -39,5 +39,4 @@
 #include <malloc.h>
 #include <bool.h>
-#include <unistd.h>
 
 /** Get sysinfo keys size
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/thread.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -41,10 +41,8 @@
 #include <str.h>
 #include <async.h>
-#include <errno.h>
-#include <as.h>
 #include "private/thread.h"
 
-#ifndef THREAD_INITIAL_STACK_PAGES
-	#define THREAD_INITIAL_STACK_PAGES  2
+#ifndef THREAD_INITIAL_STACK_PAGES_NO
+#define THREAD_INITIAL_STACK_PAGES_NO	2 
 #endif
 
@@ -67,10 +65,8 @@
 	
 	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 */
@@ -96,36 +92,36 @@
     thread_id_t *tid)
 {
-	uspace_arg_t *uarg =
-	    (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
-	if (!uarg)
-		return ENOMEM;
-	
-	size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
-	void *stack = as_area_create(AS_AREA_ANY, stack_size,
-	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
-	if (stack == AS_MAP_FAILED) {
-		free(uarg);
-		return ENOMEM;
+	char *stack;
+	uspace_arg_t *uarg;
+	int rc;
+
+	stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
+	if (!stack)
+		return -1;
+		
+	uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
+	if (!uarg) {
+		free(stack);
+		return -1;
 	}
 	
 	uarg->uspace_entry = (void *) FADDR(__thread_entry);
-	uarg->uspace_stack = stack;
-	uarg->uspace_stack_size = stack_size;
+	uarg->uspace_stack = (void *) stack;
 	uarg->uspace_thread_function = function;
 	uarg->uspace_thread_arg = arg;
 	uarg->uspace_uarg = uarg;
 	
-	int rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg,
-	    (sysarg_t) name, (sysarg_t) str_size(name), (sysarg_t) tid);
+	rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,
+	    (sysarg_t) str_size(name), (sysarg_t) tid);
 	
-	if (rc != EOK) {
+	if (rc) {
 		/*
 		 * Failed to create a new thread.
-		 * Free up the allocated data.
+		 * Free up the allocated structures.
 		 */
-		as_area_destroy(stack);
 		free(uarg);
+		free(stack);
 	}
-	
+
 	return rc;
 }
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/generic/time.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,5 +43,4 @@
 #include <ddi.h>
 #include <libc.h>
-#include <unistd.h>
 
 /** Pointer to kernel shared variables with time */
Index: uspace/lib/c/include/as.h
===================================================================
--- uspace/lib/c/include/as.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/as.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -41,7 +41,4 @@
 #include <libarch/config.h>
 
-#define AS_AREA_ANY    ((void *) -1)
-#define AS_MAP_FAILED  ((void *) -1)
-
 static inline size_t SIZE2PAGES(size_t size)
 {
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/devman.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -64,5 +64,4 @@
     size_t *);
 extern int devman_fun_get_name(devman_handle_t, char *, size_t);
-extern int devman_fun_get_driver_name(devman_handle_t, char *, size_t);
 extern int devman_fun_get_path(devman_handle_t, char *, size_t);
 extern int devman_fun_online(devman_handle_t);
Index: uspace/lib/c/include/errno.h
===================================================================
--- uspace/lib/c/include/errno.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/errno.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,4 +37,5 @@
 
 #include <abi/errno.h>
+#include <fibril.h>
 
 #define errno  (*(__errno()))
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/fibril.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -87,5 +87,4 @@
 
 extern fid_t fibril_create(int (*func)(void *), void *arg);
-extern void fibril_destroy(fid_t fid);
 extern fibril_t *fibril_setup(void);
 extern void fibril_teardown(fibril_t *f);
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/ipc/devman.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -157,5 +157,4 @@
 	DEVMAN_FUN_GET_CHILD,
 	DEVMAN_FUN_GET_NAME,
-	DEVMAN_FUN_GET_DRIVER_NAME,
 	DEVMAN_FUN_ONLINE,
 	DEVMAN_FUN_OFFLINE,
Index: uspace/lib/c/include/ipc/loc.h
===================================================================
--- uspace/lib/c/include/ipc/loc.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/ipc/loc.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -56,5 +56,4 @@
 	LOC_SERVICE_GET_ID,
 	LOC_SERVICE_GET_NAME,
-	LOC_SERVICE_GET_SERVER_NAME,
 	LOC_NAMESPACE_GET_ID,
 	LOC_CALLBACK_CREATE,
Index: uspace/lib/c/include/loc.h
===================================================================
--- uspace/lib/c/include/loc.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/loc.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -56,5 +56,4 @@
     unsigned int);
 extern int loc_service_get_name(service_id_t, char **);
-extern int loc_service_get_server_name(service_id_t, char **);
 extern int loc_namespace_get_id(const char *, service_id_t *,
     unsigned int);
Index: uspace/lib/c/include/stdarg.h
===================================================================
--- uspace/lib/c/include/stdarg.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/stdarg.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,5 +43,4 @@
 #define va_arg(ap, type)    __builtin_va_arg(ap, type)
 #define va_end(ap)          __builtin_va_end(ap)
-#define va_copy(dst, src)   __builtin_va_copy(dst, src)
 
 #endif
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/stdio.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -39,4 +39,5 @@
 #include <stdarg.h>
 #include <str.h>
+#include <adt/list.h>
 
 #ifndef NVERIFY_PRINTF
Index: uspace/lib/c/include/sys/mman.h
===================================================================
--- uspace/lib/c/include/sys/mman.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/c/include/sys/mman.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -39,5 +39,5 @@
 #include <sys/types.h>
 
-#define MAP_FAILED  AS_MAP_FAILED
+#define MAP_FAILED  ((void *) -1)
 
 #define MAP_SHARED     (1 << 0)
Index: uspace/lib/clui/tinput.h
===================================================================
--- uspace/lib/clui/tinput.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/clui/tinput.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,4 +37,6 @@
 #define LIBCLUI_TINPUT_H_
 
+#include <adt/list.h>
+#include <async.h>
 #include <inttypes.h>
 #include <io/console.h>
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/generic/driver.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -125,17 +125,19 @@
 static void driver_dev_add(ipc_callid_t iid, ipc_call_t *icall)
 {
+	char *dev_name = NULL;
+	int res;
+	
 	devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
 	devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall);
 	
 	ddf_dev_t *dev = create_device();
-	
+
 	/* Add one reference that will be dropped by driver_dev_remove() */
 	dev_add_ref(dev);
 	dev->handle = dev_handle;
-	
-	char *dev_name = NULL;
+
 	async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
 	dev->name = dev_name;
-	
+
 	/*
 	 * Currently not used, parent fun handle is stored in context
@@ -144,5 +146,5 @@
 	(void) parent_fun_handle;
 	
-	int res = driver->driver_ops->dev_add(dev);
+	res = driver->driver_ops->dev_add(dev);
 	
 	if (res != EOK) {
@@ -161,8 +163,12 @@
 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall)
 {
-	devman_handle_t devh = IPC_GET_ARG1(*icall);
+	devman_handle_t devh;
+	ddf_dev_t *dev;
+	int rc;
+	
+	devh = IPC_GET_ARG1(*icall);
 	
 	fibril_mutex_lock(&devices_mutex);
-	ddf_dev_t *dev = driver_get_device(devh);
+	dev = driver_get_device(devh);
 	if (dev != NULL)
 		dev_add_ref(dev);
@@ -173,6 +179,4 @@
 		return;
 	}
-	
-	int rc;
 	
 	if (driver->driver_ops->dev_remove != NULL)
@@ -189,8 +193,12 @@
 static void driver_dev_gone(ipc_callid_t iid, ipc_call_t *icall)
 {
-	devman_handle_t devh = IPC_GET_ARG1(*icall);
+	devman_handle_t devh;
+	ddf_dev_t *dev;
+	int rc;
+	
+	devh = IPC_GET_ARG1(*icall);
 	
 	fibril_mutex_lock(&devices_mutex);
-	ddf_dev_t *dev = driver_get_device(devh);
+	dev = driver_get_device(devh);
 	if (dev != NULL)
 		dev_add_ref(dev);
@@ -201,6 +209,4 @@
 		return;
 	}
-	
-	int rc;
 	
 	if (driver->driver_ops->dev_gone != NULL)
@@ -217,5 +223,9 @@
 static void driver_fun_online(ipc_callid_t iid, ipc_call_t *icall)
 {
-	devman_handle_t funh = IPC_GET_ARG1(*icall);
+	devman_handle_t funh;
+	ddf_fun_t *fun;
+	int rc;
+	
+	funh = IPC_GET_ARG1(*icall);
 	
 	/*
@@ -226,5 +236,5 @@
 	fibril_mutex_lock(&functions_mutex);
 	
-	ddf_fun_t *fun = driver_get_function(funh);
+	fun = driver_get_function(funh);
 	if (fun != NULL)
 		fun_add_ref(fun);
@@ -238,6 +248,4 @@
 	
 	/* Call driver entry point */
-	int rc;
-	
 	if (driver->driver_ops->fun_online != NULL)
 		rc = driver->driver_ops->fun_online(fun);
@@ -252,5 +260,9 @@
 static void driver_fun_offline(ipc_callid_t iid, ipc_call_t *icall)
 {
-	devman_handle_t funh = IPC_GET_ARG1(*icall);
+	devman_handle_t funh;
+	ddf_fun_t *fun;
+	int rc;
+	
+	funh = IPC_GET_ARG1(*icall);
 	
 	/*
@@ -261,5 +273,5 @@
 	fibril_mutex_lock(&functions_mutex);
 	
-	ddf_fun_t *fun = driver_get_function(funh);
+	fun = driver_get_function(funh);
 	if (fun != NULL)
 		fun_add_ref(fun);
@@ -273,6 +285,4 @@
 	
 	/* Call driver entry point */
-	int rc;
-	
 	if (driver->driver_ops->fun_offline != NULL)
 		rc = driver->driver_ops->fun_offline(fun);
@@ -587,10 +597,12 @@
 void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size)
 {
+	void *data;
+
 	assert(dev->driver_data == NULL);
-	
-	void *data = calloc(1, size);
+
+	data = calloc(1, size);
 	if (data == NULL)
 		return NULL;
-	
+
 	dev->driver_data = data;
 	return data;
@@ -622,15 +634,17 @@
 ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name)
 {
-	ddf_fun_t *fun = create_function();
+	ddf_fun_t *fun;
+
+	fun = create_function();
 	if (fun == NULL)
 		return NULL;
-	
+
 	/* Add one reference that will be dropped by ddf_fun_destroy() */
 	fun->dev = dev;
 	fun_add_ref(fun);
-	
+
 	fun->bound = false;
 	fun->ftype = ftype;
-	
+
 	fun->name = str_dup(name);
 	if (fun->name == NULL) {
@@ -638,5 +652,5 @@
 		return NULL;
 	}
-	
+
 	return fun;
 }
@@ -645,11 +659,13 @@
 void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size)
 {
+	void *data;
+
 	assert(fun->bound == false);
 	assert(fun->driver_data == NULL);
-	
-	void *data = calloc(1, size);
+
+	data = calloc(1, size);
 	if (data == NULL)
 		return NULL;
-	
+
 	fun->driver_data = data;
 	return data;
@@ -661,11 +677,10 @@
  * must not be bound.
  *
- * @param fun Function to destroy
- *
+ * @param fun		Function to destroy
  */
 void ddf_fun_destroy(ddf_fun_t *fun)
 {
 	assert(fun->bound == false);
-	
+
 	/*
 	 * Drop the reference added by ddf_fun_create(). This will deallocate
@@ -682,5 +697,4 @@
 	if (fun->ops == NULL)
 		return NULL;
-	
 	return fun->ops->interfaces[idx];
 }
@@ -695,8 +709,6 @@
  * the same name.
  *
- * @param fun Function to bind
- *
- * @return EOK on success or negative error code
- *
+ * @param fun		Function to bind
+ * @return		EOK on success or negative error code
  */
 int ddf_fun_bind(ddf_fun_t *fun)
@@ -705,6 +717,8 @@
 	assert(fun->name != NULL);
 	
+	int res;
+	
 	add_to_functions_list(fun);
-	int res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
+	res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
 	    fun->dev->handle, &fun->handle);
 	if (res != EOK) {
@@ -722,17 +736,17 @@
  * the function invisible to the system.
  *
- * @param fun Function to unbind
- *
- * @return EOK on success or negative error code
- *
+ * @param fun		Function to unbind
+ * @return		EOK on success or negative error code
  */
 int ddf_fun_unbind(ddf_fun_t *fun)
 {
+	int res;
+	
 	assert(fun->bound == true);
 	
-	int res = devman_remove_function(fun->handle);
+	res = devman_remove_function(fun->handle);
 	if (res != EOK)
 		return res;
-	
+
 	remove_from_functions_list(fun);
 	
@@ -743,14 +757,14 @@
 /** Online function.
  *
- * @param fun Function to online
- *
- * @return EOK on success or negative error code
- *
+ * @param fun		Function to online
+ * @return		EOK on success or negative error code
  */
 int ddf_fun_online(ddf_fun_t *fun)
 {
+	int res;
+	
 	assert(fun->bound == true);
 	
-	int res = devman_drv_fun_online(fun->handle);
+	res = devman_drv_fun_online(fun->handle);
 	if (res != EOK)
 		return res;
@@ -761,14 +775,14 @@
 /** Offline function.
  *
- * @param fun Function to offline
- *
- * @return EOK on success or negative error code
- *
+ * @param fun		Function to offline
+ * @return		EOK on success or negative error code
  */
 int ddf_fun_offline(ddf_fun_t *fun)
 {
+	int res;
+	
 	assert(fun->bound == true);
 	
-	int res = devman_drv_fun_offline(fun->handle);
+	res = devman_drv_fun_offline(fun->handle);
 	if (res != EOK)
 		return res;
@@ -782,19 +796,18 @@
  * Cannot be called when the function node is bound.
  *
- * @param fun          Function
- * @param match_id_str Match string
- * @param match_score  Match score
- *
- * @return EOK on success.
- * @return ENOMEM if out of memory.
- *
+ * @param fun			Function
+ * @param match_id_str		Match string
+ * @param match_score		Match score
+ * @return			EOK on success, ENOMEM if out of memory.
  */
 int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
     int match_score)
 {
+	match_id_t *match_id;
+	
 	assert(fun->bound == false);
 	assert(fun->ftype == fun_inner);
 	
-	match_id_t *match_id = create_match_id();
+	match_id = create_match_id();
 	if (match_id == NULL)
 		return ENOMEM;
@@ -818,5 +831,4 @@
  *
  * Must only be called when the function is bound.
- *
  */
 int ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name)
@@ -830,4 +842,6 @@
 int ddf_driver_main(driver_t *drv)
 {
+	int rc;
+
 	/*
 	 * Remember the driver structure - driver_ops will be called by generic
@@ -844,5 +858,5 @@
 	 */
 	async_set_client_connection(driver_connection);
-	int rc = devman_driver_register(driver->name);
+	rc = devman_driver_register(driver->name);
 	if (rc != EOK) {
 		printf("Error: Failed to register driver with device manager "
@@ -850,5 +864,5 @@
 		    str_error(rc));
 		
-		return rc;
+		return 1;
 	}
 	
@@ -856,10 +870,10 @@
 	rc = task_retval(0);
 	if (rc != EOK)
-		return rc;
-	
+		return 1;
+
 	async_manager();
 	
 	/* Never reached. */
-	return EOK;
+	return 0;
 }
 
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/generic/interrupt.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -117,6 +117,6 @@
 }
 
-static void add_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx)
+static void
+add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
 {
 	fibril_mutex_lock(&list->mutex);
@@ -134,6 +134,6 @@
 }
 
-static interrupt_context_t *find_interrupt_context_by_id(
-    interrupt_context_list_t *list, int id)
+static interrupt_context_t *
+find_interrupt_context_by_id(interrupt_context_list_t *list, int id)
 {
 	interrupt_context_t *ctx;
@@ -153,6 +153,6 @@
 }
 
-static interrupt_context_t *find_interrupt_context(
-    interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
+static interrupt_context_t *
+find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
 {
 	interrupt_context_t *ctx;
@@ -173,6 +173,7 @@
 
 
-int register_interrupt_handler(ddf_dev_t *dev, int irq,
-    interrupt_handler_t *handler, irq_code_t *pseudocode)
+int
+register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler,
+    irq_code_t *pseudocode)
 {
 	interrupt_context_t *ctx = create_interrupt_context();
@@ -192,5 +193,5 @@
 		delete_interrupt_context(ctx);
 	}
-	
+
 	return res;
 }
Index: uspace/lib/drv/generic/log.c
===================================================================
--- uspace/lib/drv/generic/log.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/generic/log.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,11 +33,11 @@
 #include <io/log.h>
 #include <stdarg.h>
+
 #include <ddf/log.h>
 
 /** Initialize the logging system.
  *
- * @param drv_name Driver name, will be printed as part of message
- * @param level    Minimum message level to print
- *
+ * @param drv_name	Driver name, will be printed as part of message
+ * @param level		Minimum message level to print
  */
 int ddf_log_init(const char *drv_name, log_level_t level)
@@ -48,14 +48,13 @@
 /** Log a driver message.
  *
- * @param level Message verbosity level. Message is only printed
- *              if verbosity is less than or equal to current
- *              reporting level.
- * @param fmt   Format string (no trailing newline)
- *
+ * @param level		Message verbosity level. Message is only printed
+ *			if verbosity is less than or equal to current
+ *			reporting level.
+ * @param fmt		Format string (no trailing newline)
  */
 void ddf_msg(log_level_t level, const char *fmt, ...)
 {
 	va_list args;
-	
+
 	va_start(args, fmt);
 	log_msgv(level, fmt, args);
Index: uspace/lib/drv/generic/logbuf.c
===================================================================
--- uspace/lib/drv/generic/logbuf.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/generic/logbuf.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -35,5 +35,4 @@
 #include <ddf/log.h>
 #include <assert.h>
-#include <unistd.h>
 
 /** Formatting string for printing number of not-printed items. */
Index: uspace/lib/drv/include/ddf/driver.h
===================================================================
--- uspace/lib/drv/include/ddf/driver.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/include/ddf/driver.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -81,5 +81,4 @@
 	 */
 	devman_handle_t handle;
-	
 	/** Reference count */
 	atomic_t refcnt;
@@ -105,8 +104,6 @@
 	/** True if bound to the device manager */
 	bool bound;
-	
 	/** Function indentifier (asigned by device manager) */
 	devman_handle_t handle;
-	
 	/** Reference count */
 	atomic_t refcnt;
@@ -117,17 +114,12 @@
 	/** Function type */
 	fun_type_t ftype;
-	
 	/** Function name */
 	const char *name;
-	
 	/** List of device ids for driver matching */
 	match_id_list_t match_ids;
-	
 	/** Driver-specific data associated with this function */
 	void *driver_data;
-	
 	/** Implementation of operations provided by this function */
 	ddf_dev_ops_t *ops;
-	
 	/** Connection handler or @c NULL to use the DDF default handler. */
 	async_client_conn_t conn_handler;
@@ -145,14 +137,10 @@
 	/** Callback method for passing a new device to the device driver */
 	int (*dev_add)(ddf_dev_t *);
-	
 	/** Ask driver to remove a device */
 	int (*dev_remove)(ddf_dev_t *);
-	
 	/** Inform driver a device disappeared */
 	int (*dev_gone)(ddf_dev_t *);
-	
 	/** Ask driver to online a specific function */
 	int (*fun_online)(ddf_fun_t *);
-	
 	/** Ask driver to offline a specific function */
 	int (*fun_offline)(ddf_fun_t *);
Index: uspace/lib/drv/include/ddf/interrupt.h
===================================================================
--- uspace/lib/drv/include/ddf/interrupt.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/include/ddf/interrupt.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,10 +36,9 @@
 #define DDF_INTERRUPT_H_
 
-#include <libarch/common.h>
-#include <libarch/types.h>
 #include <abi/ddi/irq.h>
 #include <adt/list.h>
 #include <ddi.h>
 #include <fibril_synch.h>
+
 #include "driver.h"
 #include "../dev_iface.h"
Index: uspace/lib/drv/include/ops/hw_res.h
===================================================================
--- uspace/lib/drv/include/ops/hw_res.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/include/ops/hw_res.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -39,4 +39,5 @@
 #include <device/hw_res.h>
 #include <sys/types.h>
+
 #include "../ddf/driver.h"
 
Index: uspace/lib/drv/include/ops/nic.h
===================================================================
--- uspace/lib/drv/include/ops/nic.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/drv/include/ops/nic.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -40,4 +40,5 @@
 #include <nic/nic.h>
 #include <sys/time.h>
+
 #include "../ddf/driver.h"
 
Index: uspace/lib/fb/imgmap.c
===================================================================
--- uspace/lib/fb/imgmap.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/fb/imgmap.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -420,7 +420,7 @@
 	
 	if ((flags & IMGMAP_FLAG_SHARED) == IMGMAP_FLAG_SHARED) {
-		imgmap = (imgmap_t *) as_area_create(AS_AREA_ANY, size,
+		imgmap = (imgmap_t *) as_area_create((void *) -1, size,
 		    AS_AREA_READ | AS_AREA_WRITE);
-		if (imgmap == AS_MAP_FAILED)
+		if (imgmap == (void *) -1)
 			return NULL;
 	} else {
Index: uspace/lib/fb/screenbuffer.c
===================================================================
--- uspace/lib/fb/screenbuffer.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/fb/screenbuffer.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -79,7 +79,7 @@
 	
 	if ((flags & SCREENBUFFER_FLAG_SHARED) == SCREENBUFFER_FLAG_SHARED) {
-		scrbuf = (screenbuffer_t *) as_area_create(AS_AREA_ANY, size,
+		scrbuf = (screenbuffer_t *) as_area_create((void *) -1, size,
 		    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
-		if (scrbuf == AS_MAP_FAILED)
+		if (scrbuf == (void *) -1)
 			return NULL;
 	} else {
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/fs/libfs.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -339,5 +339,5 @@
 	 */
 	rc = async_share_in_start_0_0(exch, PLB_SIZE, (void *) &reg.plb_ro);
-	if (reg.plb_ro == AS_MAP_FAILED) {
+	if (reg.plb_ro == (void *) -1) {
 		async_exchange_end(exch);
 		async_forget(req);
Index: uspace/lib/nic/include/nic.h
===================================================================
--- uspace/lib/nic/include/nic.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/nic/include/nic.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -83,5 +83,4 @@
  */
 typedef void (*send_frame_handler)(nic_t *, void *, size_t);
-
 /**
  * The handler for transitions between driver states.
@@ -95,5 +94,4 @@
  */
 typedef int (*state_change_handler)(nic_t *);
-
 /**
  * Handler for unicast filtering mode change.
@@ -108,6 +106,5 @@
  */
 typedef int (*unicast_mode_change_handler)(nic_t *,
-    nic_unicast_mode_t, const nic_address_t *, size_t);
-
+	nic_unicast_mode_t, const nic_address_t *, size_t);
 /**
  * Handler for multicast filtering mode change.
@@ -122,6 +119,5 @@
  */
 typedef int (*multicast_mode_change_handler)(nic_t *,
-    nic_multicast_mode_t, const nic_address_t *, size_t);
-
+	nic_multicast_mode_t, const nic_address_t *, size_t);
 /**
  * Handler for broadcast filtering mode change.
@@ -134,5 +130,4 @@
  */
 typedef int (*broadcast_mode_change_handler)(nic_t *, nic_broadcast_mode_t);
-
 /**
  * Handler for blocked sources list change.
@@ -143,6 +138,5 @@
  */
 typedef void (*blocked_sources_change_handler)(nic_t *,
-    const nic_address_t *, size_t);
-
+	const nic_address_t *, size_t);
 /**
  * Handler for VLAN filtering mask change.
@@ -151,5 +145,4 @@
  */
 typedef void (*vlan_mask_change_handler)(nic_t *, const nic_vlan_mask_t *);
-
 /**
  * Handler called when a WOL virtue is added.
@@ -172,5 +165,4 @@
  */
 typedef int (*wol_virtue_add_handler)(nic_t *, const nic_wol_virtue_t *);
-
 /**
  * Handler called when a WOL virtue is removed.
@@ -182,5 +174,4 @@
  */
 typedef void (*wol_virtue_remove_handler)(nic_t *, const nic_wol_virtue_t *);
-
 /**
  * Handler for poll mode change.
@@ -195,6 +186,5 @@
  */
 typedef int (*poll_mode_change_handler)(nic_t *,
-    nic_poll_mode_t, const struct timeval *);
-
+	nic_poll_mode_t, const struct timeval *);
 /**
  * Event handler called when the NIC should poll its buffers for a new frame
@@ -212,5 +202,5 @@
 extern int nic_driver_init(const char *);
 extern void nic_driver_implement(driver_ops_t *, ddf_dev_ops_t *,
-    nic_iface_t *);
+	nic_iface_t *);
 
 /* Functions called in add_device */
@@ -220,13 +210,13 @@
 extern void nic_set_send_frame_handler(nic_t *, send_frame_handler);
 extern void nic_set_state_change_handlers(nic_t *,
-    state_change_handler, state_change_handler, state_change_handler);
+	state_change_handler, state_change_handler, state_change_handler);
 extern void nic_set_filtering_change_handlers(nic_t *,
-    unicast_mode_change_handler, multicast_mode_change_handler,
-    broadcast_mode_change_handler, blocked_sources_change_handler,
-    vlan_mask_change_handler);
+	unicast_mode_change_handler, multicast_mode_change_handler,
+	broadcast_mode_change_handler, blocked_sources_change_handler,
+	vlan_mask_change_handler);
 extern void nic_set_wol_virtue_change_handlers(nic_t *,
-    wol_virtue_add_handler, wol_virtue_remove_handler);
+	wol_virtue_add_handler, wol_virtue_remove_handler);
 extern void nic_set_poll_handlers(nic_t *,
-    poll_mode_change_handler, poll_request_handler);
+	poll_mode_change_handler, poll_request_handler);
 
 /* General driver functions */
@@ -264,10 +254,10 @@
 extern void nic_report_hw_filtering(nic_t *, int, int, int);
 extern void nic_query_unicast(const nic_t *,
-    nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
+	nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
 extern void nic_query_multicast(const nic_t *,
-    nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
+	nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
 extern void nic_query_broadcast(const nic_t *, nic_broadcast_mode_t *);
 extern void nic_query_blocked_sources(const nic_t *,
-    size_t, nic_address_t *, size_t *);
+	size_t, nic_address_t *, size_t *);
 extern int nic_query_vlan_mask(const nic_t *, nic_vlan_mask_t *);
 extern int nic_query_wol_max_caps(const nic_t *, nic_wv_type_t);
Index: uspace/lib/nic/include/nic_impl.h
===================================================================
--- uspace/lib/nic/include/nic_impl.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/nic/include/nic_impl.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -53,30 +53,30 @@
 extern int nic_get_stats_impl(ddf_fun_t *dev_fun, nic_device_stats_t *stats);
 extern int nic_unicast_get_mode_impl(ddf_fun_t *dev_fun,
-    nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
+	nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
 extern int nic_unicast_set_mode_impl(ddf_fun_t *dev_fun,
-    nic_unicast_mode_t, const nic_address_t *, size_t);
+	nic_unicast_mode_t, const nic_address_t *, size_t);
 extern int nic_multicast_get_mode_impl(ddf_fun_t *dev_fun,
-    nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
+	nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
 extern int nic_multicast_set_mode_impl(ddf_fun_t *dev_fun,
-    nic_multicast_mode_t, const nic_address_t *, size_t);
+	nic_multicast_mode_t, const nic_address_t *, size_t);
 extern int nic_broadcast_get_mode_impl(ddf_fun_t *, nic_broadcast_mode_t *);
 extern int nic_broadcast_set_mode_impl(ddf_fun_t *, nic_broadcast_mode_t);
 extern int nic_blocked_sources_get_impl(ddf_fun_t *,
-    size_t, nic_address_t *, size_t *);
+	size_t, nic_address_t *, size_t *);
 extern int nic_blocked_sources_set_impl(ddf_fun_t *, const nic_address_t *, size_t);
 extern int nic_vlan_get_mask_impl(ddf_fun_t *, nic_vlan_mask_t *);
 extern int nic_vlan_set_mask_impl(ddf_fun_t *, const nic_vlan_mask_t *);
 extern int nic_wol_virtue_add_impl(ddf_fun_t *dev_fun, nic_wv_type_t type,
-    const void *data, size_t length, nic_wv_id_t *new_id);
+	const void *data, size_t length, nic_wv_id_t *new_id);
 extern int nic_wol_virtue_remove_impl(ddf_fun_t *dev_fun, nic_wv_id_t id);
 extern int nic_wol_virtue_probe_impl(ddf_fun_t *dev_fun, nic_wv_id_t id,
-    nic_wv_type_t *type, size_t max_length, void *data, size_t *length);
+	nic_wv_type_t *type, size_t max_length, void *data, size_t *length);
 extern int nic_wol_virtue_list_impl(ddf_fun_t *dev_fun, nic_wv_type_t type,
-    size_t max_count, nic_wv_id_t *id_list, size_t *id_count);
+	size_t max_count, nic_wv_id_t *id_list, size_t *id_count);
 extern int nic_wol_virtue_get_caps_impl(ddf_fun_t *, nic_wv_type_t, int *);
 extern int nic_poll_get_mode_impl(ddf_fun_t *,
-    nic_poll_mode_t *, struct timeval *);
+	nic_poll_mode_t *, struct timeval *);
 extern int nic_poll_set_mode_impl(ddf_fun_t *,
-    nic_poll_mode_t, const struct timeval *);
+	nic_poll_mode_t, const struct timeval *);
 extern int nic_poll_now_impl(ddf_fun_t *);
 
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/nic/src/nic_driver.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -79,5 +79,6 @@
 }
 
-/** Fill in the default implementations for device options and NIC interface.
+/**
+ * Fill in the default implementations for device options and NIC interface.
  *
  * @param driver_ops
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/Makefile	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,5 +43,4 @@
 	fcntl.c \
 	fnmatch.c \
-	getopt.c \
 	locale.c \
 	math.c \
Index: uspace/lib/posix/errno.h
===================================================================
--- uspace/lib/posix/errno.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/errno.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -66,6 +66,4 @@
 #undef errno
 #define errno (*__posix_errno())
-
-#include "unistd.h"
 
 extern int *__posix_errno(void);
Index: pace/lib/posix/getopt.c
===================================================================
--- uspace/lib/posix/getopt.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 libposix
- * @{
- */
-/** @file Command line argument parsing.
- */
-#define LIBPOSIX_INTERNAL
-
-#include "internal/common.h"
-#include "libc/getopt.h"
-#include "getopt.h"
-
-
-int posix_getopt_long(int argc, char * const argv[],
-    const char *opt_string, const struct option *long_opts, int *long_index)
-{
-	int rc = getopt_long(argc, argv, opt_string, long_opts, long_index);
-	posix_optarg = (char *) optarg;
-	return rc;
-}
-
-int posix_getopt(int argc, char * const argv[], const char *opt_string)
-{
-	int rc = getopt(argc, argv, opt_string);
-	posix_optarg = (char *) optarg;
-	return rc;
-}
Index: pace/lib/posix/getopt.h
===================================================================
--- uspace/lib/posix/getopt.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Copyright (c) 2012 Vojtech Horky
- * 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 libposix
- * @{
- */
-/** @file Command line argument parsing.
- */
-#ifndef POSIX_GETOPT_H
-#define POSIX_GETOPT_H
-
-#include "unistd.h"
-
-/* Option Arguments */
-#define no_argument        0
-#define required_argument  1
-#define optional_argument  2
-
-#ifndef LIBPOSIX_INTERNAL
-struct option {
-	const char *name;
-	int has_arg;
-	int *flag;
-	int val;
-};
-#endif
-
-extern int posix_getopt_long(int, char * const [], const char *, const struct option *, int *);
-
-
-#ifndef LIBPOSIX_INTERNAL
-	#define getopt_long posix_getopt_long
-#endif
-
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/posix/pwd.c
===================================================================
--- uspace/lib/posix/pwd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/pwd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -38,5 +38,4 @@
 #include "string.h"
 #include "errno.h"
-#include "assert.h"
 
 static bool entry_read = false;
Index: uspace/lib/posix/stdbool.h
===================================================================
--- uspace/lib/posix/stdbool.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/stdbool.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,13 +37,6 @@
 
 #ifdef LIBC_BOOL_H_
-
-#if (!defined(POSIX_STDIO_H_)) && \
-    (!defined(POSIX_STDLIB_H_)) && \
-    (!defined(POSIX_STRING_H_))
 	#error "You can't include bool.h and stdbool.h at the same time."
 #endif
-
-#endif /* LIBC_BOOL_H */
-
 #define LIBC_BOOL_H_
 
Index: uspace/lib/posix/stdio.h
===================================================================
--- uspace/lib/posix/stdio.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/stdio.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -37,6 +37,4 @@
 #define POSIX_STDIO_H_
 
-#include "stddef.h"
-#include "unistd.h"
 #include "libc/stdio.h"
 #include "sys/types.h"
Index: uspace/lib/posix/time.c
===================================================================
--- uspace/lib/posix/time.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/time.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -45,5 +45,4 @@
 #include "errno.h"
 #include "signal.h"
-#include "assert.h"
 
 #include "libc/malloc.h"
Index: uspace/lib/posix/unistd.c
===================================================================
--- uspace/lib/posix/unistd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/unistd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -49,5 +49,4 @@
 /* Array of environment variable strings (NAME=VALUE). */
 char **posix_environ = NULL;
-char *posix_optarg;
 
 /**
Index: uspace/lib/posix/unistd.h
===================================================================
--- uspace/lib/posix/unistd.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/posix/unistd.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,7 +43,8 @@
 #define _exit exit
 
-extern char *posix_optarg;
+/* Option Arguments */
+extern char *optarg;
 extern int optind, opterr, optopt;
-extern int posix_getopt(int, char * const [], const char *);
+extern int getopt(int, char * const [], const char *);
 
 /* Environment */
@@ -143,7 +144,4 @@
 
 #ifndef LIBPOSIX_INTERNAL
-	#define getopt posix_getopt
-	#define optarg posix_optarg
-
 	#define environ posix_environ
 
Index: uspace/lib/usb/include/usb/ddfiface.h
===================================================================
--- uspace/lib/usb/include/usb/ddfiface.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usb/include/usb/ddfiface.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Implementations of DDF interfaces functions.
  */
-
 #ifndef LIBUSB_DDFIFACE_H_
 #define LIBUSB_DDFIFACE_H_
@@ -40,15 +39,14 @@
 #include <usb_iface.h>
 
-extern int usb_iface_get_hc_handle_device_impl(ddf_fun_t *, devman_handle_t *);
-extern int usb_iface_get_my_address_forward_impl(ddf_fun_t *, usb_address_t *);
+int usb_iface_get_hc_handle_device_impl(ddf_fun_t *, devman_handle_t *);
+int usb_iface_get_my_address_forward_impl(ddf_fun_t *, usb_address_t *);
 extern usb_iface_t usb_iface_hub_impl;
 
-extern int usb_iface_get_my_address_from_device_data(ddf_fun_t *, usb_address_t *);
+int usb_iface_get_my_address_from_device_data(ddf_fun_t *, usb_address_t *);
 extern usb_iface_t usb_iface_hub_child_impl;
 
-extern int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);
+int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);
 
 #endif
-
 /**
  * @}
Index: uspace/lib/usb/include/usb/debug.h
===================================================================
--- uspace/lib/usb/include/usb/debug.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usb/include/usb/debug.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -82,7 +82,7 @@
 /** Default log level. */
 #ifdef CONFIG_USB_VERBOSE
-	#define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG
+#  define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG
 #else
-	#define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_INFO
+#  define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_INFO
 #endif
 
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usb/src/ddfiface.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Implementations of DDF interfaces functions (actual implementation).
  */
-
 #include <devman.h>
 #include <async.h>
Index: uspace/lib/usb/src/hc.c
===================================================================
--- uspace/lib/usb/src/hc.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usb/src/hc.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -27,5 +27,4 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
 /** @addtogroup libusb
  * @{
@@ -34,5 +33,4 @@
  * General communication with host controller driver (implementation).
  */
-
 #include <usb/debug.h>
 
@@ -46,5 +44,4 @@
 {
 	assert(connection);
-	
 	fibril_mutex_lock(&connection->guard);
 	if (connection->ref_count == 0) {
@@ -58,14 +55,12 @@
 		}
 	}
-	
 	++connection->ref_count;
 	fibril_mutex_unlock(&connection->guard);
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 static int usb_hc_connection_del_ref(usb_hc_connection_t *connection)
 {
 	assert(connection);
-	
 	fibril_mutex_lock(&connection->guard);
 	if (connection->ref_count == 0) {
@@ -75,5 +70,4 @@
 		return EOK;
 	}
-	
 	--connection->ref_count;
 	int ret = EOK;
@@ -131,5 +125,5 @@
 	return rc;
 }
-
+/*----------------------------------------------------------------------------*/
 void usb_hc_connection_deinitialize(usb_hc_connection_t *connection)
 {
@@ -146,5 +140,5 @@
 	fibril_mutex_unlock(&connection->guard);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Open connection to host controller.
  *
@@ -156,5 +150,5 @@
 	return usb_hc_connection_add_ref(connection);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Close connection to the host controller.
  *
@@ -166,5 +160,5 @@
 	return usb_hc_connection_del_ref(connection);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Ask host controller for free address assignment.
  *
@@ -188,5 +182,5 @@
 	return ret == EOK ? address : ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_bind_address(usb_hc_connection_t * connection,
     usb_address_t address, devman_handle_t handle)
@@ -200,5 +194,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Get handle of USB device with given address.
  *
@@ -219,5 +213,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_release_address(usb_hc_connection_t *connection,
     usb_address_t address)
@@ -231,5 +225,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_register_endpoint(usb_hc_connection_t *connection,
     usb_address_t address, usb_endpoint_t endpoint, usb_transfer_type_t type,
@@ -245,5 +239,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_unregister_endpoint(usb_hc_connection_t *connection,
     usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction)
@@ -258,5 +252,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address,
     usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
@@ -272,5 +266,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 int usb_hc_write(usb_hc_connection_t *connection, usb_address_t address,
     usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
Index: uspace/lib/usbdev/include/usb/dev/driver.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/driver.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/include/usb/dev/driver.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * USB device driver framework.
  */
-
 #ifndef LIBUSBDEV_DRIVER_H_
 #define LIBUSBDEV_DRIVER_H_
Index: uspace/lib/usbdev/include/usb/dev/hub.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/hub.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/include/usb/dev/hub.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -35,5 +35,4 @@
  * For class specific requests, see usb/classes/hub.h.
  */
-
 #ifndef LIBUSBDEV_HUB_H_
 #define LIBUSBDEV_HUB_H_
@@ -44,5 +43,5 @@
 #include <usb/hc.h>
 
-extern int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
+int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
     int (*)(void *), void *, usb_address_t *, ddf_dev_ops_t *, void *,
     ddf_fun_t **);
@@ -61,5 +60,5 @@
 } usb_hub_attached_device_t;
 
-extern int usb_hub_register_device(usb_hc_connection_t *,
+int usb_hub_register_device(usb_hc_connection_t *,
     const usb_hub_attached_device_t *);
 
@@ -70,10 +69,8 @@
 	if (attached_device == NULL)
 		return EBADMEM;
-	
 	return usb_hc_release_address(conn, attached_device->address);
 }
 
 #endif
-
 /**
  * @}
Index: uspace/lib/usbdev/include/usb/dev/recognise.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/recognise.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/include/usb/dev/recognise.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * USB device recognition.
  */
-
 #ifndef LIBUSBDEV_RECOGNISE_H_
 #define LIBUSBDEV_RECOGNISE_H_
@@ -42,18 +41,17 @@
 #include <ipc/devman.h>
 
-extern int usb_device_create_match_ids_from_device_descriptor(
+int usb_device_create_match_ids_from_device_descriptor(
     const usb_standard_device_descriptor_t *, match_id_list_t *);
 
-extern int usb_device_create_match_ids_from_interface(
+int usb_device_create_match_ids_from_interface(
     const usb_standard_device_descriptor_t *,
     const usb_standard_interface_descriptor_t *, match_id_list_t *);
 
-extern int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
+int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
 
-extern int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
+int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
     ddf_dev_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
 
 #endif
-
 /**
  * @}
Index: uspace/lib/usbdev/src/altiface.c
===================================================================
--- uspace/lib/usbdev/src/altiface.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/src/altiface.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Handling alternate interface settings.
  */
-
 #include <usb/dev/driver.h>
 #include <usb/dev/request.h>
Index: uspace/lib/usbdev/src/hub.c
===================================================================
--- uspace/lib/usbdev/src/hub.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/src/hub.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Functions needed by hub drivers.
  */
-
 #include <usb/dev/hub.h>
 #include <usb/dev/pipes.h>
@@ -115,4 +114,5 @@
 	return EOK;
 }
+
 
 /** Wrapper for registering attached device to the hub.
@@ -160,5 +160,5 @@
     ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
 {
-	if ((new_fun == NULL) || (hc_conn == NULL))
+	if (new_fun == NULL || hc_conn == NULL)
 		return EINVAL;
 
Index: uspace/lib/usbdev/src/recognise.c
===================================================================
--- uspace/lib/usbdev/src/recognise.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbdev/src/recognise.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Functions for recognition of attached devices.
  */
-
 #include <sys/types.h>
 #include <fibril_synch.h>
@@ -312,5 +311,4 @@
  *	will be written.
  * @return Error code.
- *
  */
 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
@@ -320,23 +318,23 @@
 	if (child_fun == NULL || ctrl_pipe == NULL)
 		return EINVAL;
-	
+
 	if (!dev_ops && dev_data) {
 		usb_log_warning("Using standard fun ops with arbitrary "
 		    "driver data. This does not have to work.\n");
 	}
-	
+
 	/** Index to append after device name for uniqueness. */
 	static atomic_t device_name_index = {0};
 	const size_t this_device_name_index =
 	    (size_t) atomic_preinc(&device_name_index);
-	
+
 	ddf_fun_t *child = NULL;
 	int rc;
-	
+
 	/*
 	 * TODO: Once the device driver framework support persistent
 	 * naming etc., something more descriptive could be created.
 	 */
-	char child_name[12];  /* The format is: "usbAB_aXYZ", length 11 */
+	char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */
 	rc = snprintf(child_name, sizeof(child_name),
 	    "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address);
@@ -344,5 +342,5 @@
 		goto failure;
 	}
-	
+
 	child = ddf_fun_create(parent, fun_inner, child_name);
 	if (child == NULL) {
@@ -350,15 +348,14 @@
 		goto failure;
 	}
-	
-	if (dev_ops != NULL)
+
+	if (dev_ops != NULL) {
 		child->ops = dev_ops;
-	else
+	} else {
 		child->ops = &child_ops;
-	
+	}
+
 	child->driver_data = dev_data;
-	/*
-	 * Store the attached device in fun
-	 * driver data if there is no other data
-	 */
+	/* Store the attached device in fun driver data if there is no
+	 * other data */
 	if (!dev_data) {
 		usb_hub_attached_device_t *new_device = ddf_fun_data_alloc(
@@ -368,33 +365,36 @@
 			goto failure;
 		}
-		
 		new_device->address = ctrl_pipe->wire->address;
 		new_device->fun = child;
 	}
-	
+
+
 	rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
-	if (rc != EOK)
+	if (rc != EOK) {
 		goto failure;
-	
+	}
+
 	rc = ddf_fun_bind(child);
-	if (rc != EOK)
+	if (rc != EOK) {
 		goto failure;
-	
+	}
+
 	*child_fun = child;
 	return EOK;
-	
+
 failure:
 	if (child != NULL) {
 		/* We know nothing about the data if it came from outside. */
-		if (dev_data)
+		if (dev_data) {
 			child->driver_data = NULL;
-		
+		}
 		/* This takes care of match_id deallocation as well. */
 		ddf_fun_destroy(child);
 	}
-	
+
 	return rc;
 }
 
+
 /**
  * @}
Index: uspace/lib/usbhid/src/hidiface.c
===================================================================
--- uspace/lib/usbhid/src/hidiface.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbhid/src/hidiface.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Client functions for accessing USB HID interface (implementation).
  */
-
 #include <dev_iface.h>
 #include <usbhid_iface.h>
Index: uspace/lib/usbhost/include/usb/host/hcd.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/hcd.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbhost/include/usb/host/hcd.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  *
  */
-
 #ifndef LIBUSBHOST_HOST_HCD_H
 #define LIBUSBHOST_HOST_HCD_H
@@ -62,5 +61,5 @@
 	void (*ep_remove_hook)(hcd_t *, endpoint_t *);
 };
-
+/*----------------------------------------------------------------------------*/
 /** Initialize hcd_t structure.
  * Initializes device and endpoint managers. Sets data and hook pointer to NULL.
@@ -80,5 +79,5 @@
 	hcd->ep_remove_hook = NULL;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Check registered endpoints and reset toggle bit if necessary.
  * @param hcd hcd_t structure, non-null.
@@ -93,5 +92,5 @@
 	    &hcd->ep_manager, target, (const uint8_t *)setup_data);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Data retrieve wrapper.
  * @param fun ddf function, non-null.
@@ -103,9 +102,8 @@
 	return fun->driver_data;
 }
-
+/*----------------------------------------------------------------------------*/
 extern usbhc_iface_t hcd_iface;
 
 #endif
-
 /**
  * @}
Index: uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
===================================================================
--- uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -26,5 +26,4 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
 /** @addtogroup libusbhost
  * @{
@@ -33,5 +32,4 @@
  * USB transfer transaction structures.
  */
-
 #ifndef LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
 #define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
@@ -117,5 +115,5 @@
 void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     const void* data, size_t size, int error);
-
+/*----------------------------------------------------------------------------*/
 /** Finish batch using stored error value and transferred size.
  *
@@ -130,5 +128,5 @@
 	    instance, data, instance->transfered_size, instance->error);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Determine batch direction based on the callbacks present
  * @param[in] instance Batch structure to use, non-null.
@@ -155,7 +153,5 @@
 	assert(false);
 }
-
 #endif
-
 /**
  * @}
Index: uspace/lib/usbhost/src/iface.c
===================================================================
--- uspace/lib/usbhost/src/iface.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbhost/src/iface.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -26,5 +26,4 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
 /** @addtogroup libusbhost
  * @{
@@ -33,5 +32,4 @@
  * @brief HCD DDF interface implementation
  */
-
 #include <ddf/driver.h>
 #include <errno.h>
@@ -100,5 +98,5 @@
 	return ret;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Calls ep_add_hook upon endpoint registration.
  * @param ep Endpoint to be registered.
@@ -115,5 +113,5 @@
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Calls ep_remove_hook upon endpoint removal.
  * @param ep Endpoint to be unregistered.
@@ -128,5 +126,5 @@
 		hcd->ep_remove_hook(hcd, ep);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Calls ep_remove_hook upon endpoint removal. Prints warning.
  * @param ep Endpoint to be unregistered.
@@ -143,5 +141,5 @@
 		hcd->ep_remove_hook(hcd, ep);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Request address interface function.
  *
@@ -166,5 +164,5 @@
 	    &hcd->dev_manager, address, strict, speed);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Bind address interface function.
  *
@@ -185,5 +183,5 @@
 	    &hcd->dev_manager, address, handle);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Find device handle by address interface function.
  *
@@ -202,5 +200,5 @@
 	    &hcd->dev_manager, address, handle, NULL);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Release address interface function.
  *
@@ -220,5 +218,5 @@
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Register endpoint interface function.
  * @param fun DDF function.
@@ -256,5 +254,5 @@
 	    register_helper, hcd);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Unregister endpoint interface function.
  * @param fun DDF function.
@@ -276,5 +274,5 @@
 	    endpoint, direction, unregister_helper, hcd);
 }
-
+/*----------------------------------------------------------------------------*/
 /** Inbound communication interface function.
  * @param fun DDF function.
@@ -294,5 +292,5 @@
 	    setup_data, callback, NULL, arg, "READ");
 }
-
+/*----------------------------------------------------------------------------*/
 /** Outbound communication interface function.
  * @param fun DDF function.
@@ -312,5 +310,5 @@
 	    setup_data, NULL, callback, arg, "WRITE");
 }
-
+/*----------------------------------------------------------------------------*/
 /** usbhc Interface implementation using hcd_t from libusbhost library. */
 usbhc_iface_t hcd_iface = {
@@ -326,5 +324,4 @@
 	.write = usb_write,
 };
-
 /**
  * @}
Index: uspace/lib/usbvirt/src/device.c
===================================================================
--- uspace/lib/usbvirt/src/device.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/lib/usbvirt/src/device.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -33,5 +33,4 @@
  * Virtual USB device main routines.
  */
-
 #include <errno.h>
 #include <str.h>
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -191,5 +191,5 @@
 	}
 
-	printf("%s: Accepting connections\n", NAME);
+	printf(NAME ": Accepting connections\n");
 	task_retval(0);
 	async_manager();
@@ -243,28 +243,31 @@
 static int ata_bd_init(void)
 {
+	void *vaddr;
+	int rc;
+	
 	async_set_client_connection(ata_bd_connection);
-	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register driver.\n", NAME);
+	rc = loc_server_register(NAME);
+	if (rc < 0) {
+		printf(NAME ": Unable to register driver.\n");
 		return rc;
 	}
-	
-	void *vaddr;
+
 	rc = pio_enable((void *) cmd_physical, sizeof(ata_cmd_t), &vaddr);
 	if (rc != EOK) {
-		printf("%s: Could not initialize device I/O space.\n", NAME);
+		printf(NAME ": Could not initialize device I/O space.\n");
 		return rc;
 	}
-	
+
 	cmd = vaddr;
-	
+
 	rc = pio_enable((void *) ctl_physical, sizeof(ata_ctl_t), &vaddr);
 	if (rc != EOK) {
-		printf("%s: Could not initialize device I/O space.\n", NAME);
+		printf(NAME ": Could not initialize device I/O space.\n");
 		return rc;
 	}
-	
+
 	ctl = vaddr;
-	
+
+
 	return EOK;
 }
@@ -308,5 +311,5 @@
 
 	(void) async_share_out_finalize(callid, &fs_va);
-	if (fs_va == AS_MAP_FAILED) {
+	if (fs_va == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -119,13 +119,13 @@
 	rc = loc_service_register(device_name, &service_id);
 	if (rc != EOK) {
-		printf("%s: Unable to register device '%s'.\n",
-		    NAME, device_name);
+		printf(NAME ": Unable to register device '%s'.\n",
+			device_name);
 		return rc;
 	}
-	
-	printf("%s: Accepting connections\n", NAME);
+
+	printf(NAME ": Accepting connections\n");
 	task_retval(0);
 	async_manager();
-	
+
 	/* Not reached */
 	return 0;
@@ -139,30 +139,33 @@
 static int file_bd_init(const char *fname)
 {
+	int rc;
+	long img_size;
+	
 	async_set_client_connection(file_bd_connection);
-	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register driver.\n", NAME);
+	rc = loc_server_register(NAME);
+	if (rc < 0) {
+		printf(NAME ": Unable to register driver.\n");
 		return rc;
 	}
-	
+
 	img = fopen(fname, "rb+");
 	if (img == NULL)
 		return EINVAL;
-	
+
 	if (fseek(img, 0, SEEK_END) != 0) {
 		fclose(img);
 		return EIO;
 	}
-	
-	off64_t img_size = ftell(img);
+
+	img_size = ftell(img);
 	if (img_size < 0) {
 		fclose(img);
 		return EIO;
 	}
-	
+
 	num_blocks = img_size / block_size;
-	
+
 	fibril_mutex_initialize(&dev_lock);
-	
+
 	return EOK;
 }
@@ -189,5 +192,5 @@
 
 	(void) async_share_out_finalize(callid, &fs_va);
-	if (fs_va == AS_MAP_FAILED) {
+	if (fs_va == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -122,34 +122,33 @@
 static int gxe_bd_init(void)
 {
+	void *vaddr;
+	int rc, i;
+	char name[16];
+	
 	async_set_client_connection(gxe_bd_connection);
-	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register driver.\n", NAME);
+	rc = loc_server_register(NAME);
+	if (rc < 0) {
+		printf(NAME ": Unable to register driver.\n");
 		return rc;
 	}
-	
-	void *vaddr;
+
 	rc = pio_enable((void *) dev_physical, sizeof(gxe_bd_t), &vaddr);
 	if (rc != EOK) {
-		printf("%s: Could not initialize device I/O space.\n", NAME);
+		printf(NAME ": Could not initialize device I/O space.\n");
 		return rc;
 	}
-	
+
 	dev = vaddr;
-	
-	for (unsigned int i = 0; i < MAX_DISKS; i++) {
-		char name[16];
-		
-		snprintf(name, 16, "%s/disk%u", NAMESPACE, i);
+
+	for (i = 0; i < MAX_DISKS; i++) {
+		snprintf(name, 16, "%s/disk%d", NAMESPACE, i);
 		rc = loc_service_register(name, &service_id[i]);
 		if (rc != EOK) {
-			printf("%s: Unable to register device %s.\n", NAME,
-			    name);
+			printf(NAME ": Unable to register device %s.\n", name);
 			return rc;
 		}
-		
 		fibril_mutex_initialize(&dev_lock[i]);
 	}
-	
+
 	return EOK;
 }
@@ -196,5 +195,5 @@
 
 	(void) async_share_out_finalize(callid, &fs_va);
-	if (fs_va == AS_MAP_FAILED) {
+	if (fs_va == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -170,5 +170,5 @@
 		return rc;
 	}
-	
+
 	/*
 	 * Create partition devices.
@@ -350,5 +350,5 @@
 
 	(void) async_share_out_finalize(callid, &fs_va);
-	if (fs_va == AS_MAP_FAILED) {
+	if (fs_va == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -427,5 +427,5 @@
 
 	(void) async_share_out_finalize(callid, &fs_va);
-	if (fs_va == AS_MAP_FAILED) {
+	if (fs_va == (void *) -1) {
 		async_answer_0(callid, EHANGUP);
 		return;
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/bd/rd/rd.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -106,5 +106,5 @@
 	if (async_share_out_receive(&callid, &comm_size, &flags)) {
 		(void) async_share_out_finalize(callid, &fs_va);
-		if (fs_va == AS_MAP_FAILED) {
+		if (fs_va == (void *) -1) {
 			async_answer_0(callid, EHANGUP);
 			return;
@@ -237,5 +237,5 @@
 	async_set_client_connection(rd_connection);
 	ret = loc_server_register(NAME);
-	if (ret != EOK) {
+	if (ret < 0) {
 		printf("%s: Unable to register driver (%d)\n", NAME, ret);
 		return false;
Index: uspace/srv/clipboard/clipboard.c
===================================================================
--- uspace/srv/clipboard/clipboard.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/clipboard/clipboard.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -181,7 +181,7 @@
 	
 	async_set_client_connection(clip_connection);
-	int rc = service_register(SERVICE_CLIPBOARD);
-	if (rc != EOK)
-		return rc;
+	
+	if (service_register(SERVICE_CLIPBOARD) != EOK)
+		return -1;
 	
 	printf("%s: Accepting connections\n", NAME);
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/devman/devman.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -210,4 +210,5 @@
 };
 
+
 /** Represents device tree. */
 typedef struct dev_tree {
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/devman/main.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -245,5 +245,5 @@
 	
 	fibril_rwlock_write_lock(&device_tree.rwlock);
-	
+
 	if (fun->state == FUN_ON_LINE) {
 		fibril_rwlock_write_unlock(&device_tree.rwlock);
@@ -259,5 +259,5 @@
 			return ENOMEM;
 		}
-		
+
 		insert_dev_node(&device_tree, dev, fun);
 		dev_add_ref(dev);
@@ -272,5 +272,4 @@
 		/* Give one reference over to assign_driver_fibril(). */
 		dev_add_ref(dev);
-		
 		/*
 		 * Try to find a suitable driver and assign it to the device.  We do
@@ -289,6 +288,7 @@
 		}
 		fibril_add_ready(assign_fibril);
-	} else
+	} else {
 		loc_register_tree_function(fun, &device_tree);
+	}
 	
 	fibril_rwlock_write_unlock(&device_tree.rwlock);
@@ -419,7 +419,5 @@
 	
 	/* Check that function with same name is not there already. */
-	fun_node_t *tfun = find_fun_node_in_device(tree, pdev, fun_name);
-	if (tfun) {
-		fun_del_ref(tfun);	/* drop the new unwanted reference */
+	if (find_fun_node_in_device(tree, pdev, fun_name) != NULL) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
 		dev_del_ref(pdev);
@@ -857,68 +855,4 @@
 }
 
-/** Get function driver name. */
-static void devman_fun_get_driver_name(ipc_callid_t iid, ipc_call_t *icall)
-{
-	devman_handle_t handle = IPC_GET_ARG1(*icall);
-
-	fun_node_t *fun = find_fun_node(&device_tree, handle);
-	if (fun == NULL) {
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-
-	ipc_callid_t data_callid;
-	size_t data_len;
-	if (!async_data_read_receive(&data_callid, &data_len)) {
-		async_answer_0(iid, EINVAL);
-		fun_del_ref(fun);
-		return;
-	}
-
-	void *buffer = malloc(data_len);
-	if (buffer == NULL) {
-		async_answer_0(data_callid, ENOMEM);
-		async_answer_0(iid, ENOMEM);
-		fun_del_ref(fun);
-		return;
-	}
-
-	fibril_rwlock_read_lock(&device_tree.rwlock);
-
-	/* Check function state */
-	if (fun->state == FUN_REMOVED) {
-		fibril_rwlock_read_unlock(&device_tree.rwlock);
-		free(buffer);
-
-		async_answer_0(data_callid, ENOENT);
-		async_answer_0(iid, ENOENT);
-		fun_del_ref(fun);
-		return;
-	}
-
-	/* Check whether function has a driver */
-	if (fun->child == NULL || fun->child->drv == NULL) {
-		fibril_rwlock_read_unlock(&device_tree.rwlock);
-		free(buffer);
-
-		async_answer_0(data_callid, EINVAL);
-		async_answer_0(iid, EINVAL);
-		fun_del_ref(fun);
-		return;
-	}
-
-	size_t sent_length = str_size(fun->child->drv->name);
-	if (sent_length > data_len) {
-		sent_length = data_len;
-	}
-
-	async_data_read_finalize(data_callid, fun->child->drv->name,
-	    sent_length);
-	async_answer_0(iid, EOK);
-
-	fibril_rwlock_read_unlock(&device_tree.rwlock);
-	fun_del_ref(fun);
-	free(buffer);
-}
 
 /** Get device path. */
@@ -1149,7 +1083,4 @@
 			devman_fun_get_name(callid, &call);
 			break;
-		case DEVMAN_FUN_GET_DRIVER_NAME:
-			devman_fun_get_driver_name(callid, &call);
-			break;
 		case DEVMAN_FUN_GET_PATH:
 			devman_fun_get_path(callid, &call);
@@ -1218,5 +1149,4 @@
 		if (dev->pfun->dev != NULL)
 			driver = dev->pfun->dev->drv;
-		
 		fwd_h = dev->pfun->handle;
 	} else if (dev->state == DEVICE_USABLE) {
@@ -1224,5 +1154,5 @@
 		driver = dev->drv;
 		assert(driver != NULL);
-		
+
 		fwd_h = handle;
 	}
@@ -1251,9 +1181,9 @@
 
 	if (fun != NULL) {
-		log_msg(LVL_DEBUG,
+		log_msg(LVL_DEBUG, 
 		    "Forwarding request for `%s' function to driver `%s'.",
 		    fun->pathname, driver->name);
 	} else {
-		log_msg(LVL_DEBUG,
+		log_msg(LVL_DEBUG, 
 		    "Forwarding request for `%s' device to driver `%s'.",
 		    dev->pfun->pathname, driver->name);
@@ -1263,9 +1193,8 @@
 	async_forward_fast(iid, exch, method, fwd_h, 0, IPC_FF_NONE);
 	async_exchange_end(exch);
-	
+
 cleanup:
 	if (dev != NULL)
 		dev_del_ref(dev);
-	
 	if (fun != NULL)
 		fun_del_ref(fun);
@@ -1370,7 +1299,7 @@
 		return false;
 	}
-	
+
 	log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.");
-	
+
 	/* Create root device node. */
 	if (!init_device_tree(&device_tree, &drivers_list)) {
@@ -1378,5 +1307,5 @@
 		return false;
 	}
-	
+
 	/*
 	 * Caution: As the device manager is not a real loc
@@ -1393,10 +1322,9 @@
 int main(int argc, char *argv[])
 {
-	printf("%s: HelenOS Device Manager\n", NAME);
-	
-	int rc = log_init(NAME, LVL_WARN);
-	if (rc != EOK) {
-		printf("%s: Error initializing logging subsystem.\n", NAME);
-		return rc;
+	printf(NAME ": HelenOS Device Manager\n");
+
+	if (log_init(NAME, LVL_WARN) != EOK) {
+		printf(NAME ": Error initializing logging subsystem.\n");
+		return -1;
 	}
 	
@@ -1405,21 +1333,20 @@
 	async_set_client_data_destructor(devman_client_data_destroy);
 	async_set_client_connection(devman_connection);
-	
+
 	if (!devman_init()) {
 		log_msg(LVL_ERROR, "Error while initializing service.");
 		return -1;
 	}
-	
+
 	/* Register device manager at naming service. */
-	rc = service_register(SERVICE_DEVMAN);
-	if (rc != EOK) {
+	if (service_register(SERVICE_DEVMAN) != EOK) {
 		log_msg(LVL_ERROR, "Failed registering as a service.");
-		return rc;
-	}
-	
-	printf("%s: Accepting connections.\n", NAME);
+		return -1;
+	}
+
+	printf(NAME ": Accepting connections.\n");
 	task_retval(0);
 	async_manager();
-	
+
 	/* Never reached. */
 	return 0;
Index: uspace/srv/fs/fat/fat_dentry.c
===================================================================
--- uspace/srv/fs/fat/fat_dentry.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/fs/fat/fat_dentry.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -43,5 +43,4 @@
 #include <byteorder.h>
 #include <assert.h>
-#include <unistd.h>
 
 /** Compare path component with the name read from the dentry.
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/console/console.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -852,5 +852,5 @@
 	async_set_client_connection(client_connection);
 	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
+	if (rc < 0) {
 		printf("%s: Unable to register server (%s)\n", NAME,
 		    str_error(rc));
Index: uspace/srv/hid/fb/fb.c
===================================================================
--- uspace/srv/hid/fb/fb.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/fb/fb.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -305,5 +305,5 @@
 	
 	int rc = async_share_out_finalize(callid, &frontbuf->data);
-	if ((rc != EOK) || (frontbuf->data == AS_MAP_FAILED)) {
+	if ((rc != EOK) || (frontbuf->data == (void *) -1)) {
 		free(frontbuf);
 		async_answer_0(iid, ENOMEM);
@@ -348,5 +348,5 @@
 	
 	int rc = async_share_out_finalize(callid, &imagemap->data);
-	if ((rc != EOK) || (imagemap->data == AS_MAP_FAILED)) {
+	if ((rc != EOK) || (imagemap->data == (void *) -1)) {
 		free(imagemap);
 		async_answer_0(iid, ENOMEM);
@@ -990,6 +990,6 @@
 	int rc = loc_server_register(NAME);
 	if (rc != EOK) {
-		printf("%s: Unable to register driver\n", NAME);
-		return rc;
+		printf("%s: Unable to register driver (%d)\n", NAME, rc);
+		return 1;
 	}
 	
Index: uspace/srv/hid/input/ctl/kbdev.c
===================================================================
--- uspace/srv/hid/input/ctl/kbdev.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/input/ctl/kbdev.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -68,5 +68,5 @@
 	/** Link to generic keyboard device */
 	kbd_dev_t *kbd_dev;
-	
+
 	/** Session with kbdev device */
 	async_sess_t *sess;
@@ -75,8 +75,10 @@
 static kbdev_t *kbdev_new(kbd_dev_t *kdev)
 {
-	kbdev_t *kbdev = calloc(1, sizeof(kbdev_t));
+	kbdev_t *kbdev;
+
+	kbdev = calloc(1, sizeof(kbdev_t));
 	if (kbdev == NULL)
 		return NULL;
-	
+
 	kbdev->kbd_dev = kdev;
 
@@ -88,5 +90,4 @@
 	if (kbdev->sess != NULL)
 		async_hangup(kbdev->sess);
-	
 	free(kbdev);
 }
@@ -94,31 +95,35 @@
 static int kbdev_ctl_init(kbd_dev_t *kdev)
 {
-	async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
-	    kdev->svc_id, 0);
+	async_sess_t *sess;
+	async_exch_t *exch;
+	kbdev_t *kbdev;
+	int rc;
+
+	sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
 	if (sess == NULL) {
 		printf("%s: Failed starting session with '%s.'\n", NAME,
 		    kdev->svc_name);
-		return ENOENT;
+		return -1;
 	}
-	
-	kbdev_t *kbdev = kbdev_new(kdev);
+
+	kbdev = kbdev_new(kdev);
 	if (kbdev == NULL) {
 		printf("%s: Failed allocating device structure for '%s'.\n",
 		    NAME, kdev->svc_name);
 		async_hangup(sess);
-		return ENOMEM;
+		return -1;
 	}
-	
+
 	kbdev->sess = sess;
-	
-	async_exch_t *exch = async_exchange_begin(sess);
+
+	exch = async_exchange_begin(sess);
 	if (exch == NULL) {
 		printf("%s: Failed starting exchange with '%s'.\n", NAME,
 		    kdev->svc_name);
 		kbdev_destroy(kbdev);
-		return ENOENT;
+		return -1;
 	}
-	
-	int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
+
+	rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
 	if (rc != EOK) {
 		printf("%s: Failed creating callback connection from '%s'.\n",
@@ -126,9 +131,9 @@
 		async_exchange_end(exch);
 		kbdev_destroy(kbdev);
-		return rc;
+		return -1;
 	}
-	
+
 	async_exchange_end(exch);
-	
+
 	kdev->ctl_private = (void *) kbdev;
 	return 0;
@@ -137,9 +142,13 @@
 static void kbdev_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
 {
-	async_sess_t *sess = ((kbdev_t *) kdev->ctl_private)->sess;
-	async_exch_t *exch = async_exchange_begin(sess);
+	async_sess_t *sess;
+	async_exch_t *exch;
+
+	sess = ((kbdev_t *) kdev->ctl_private)->sess;
+
+	exch = async_exchange_begin(sess);
 	if (!exch)
 		return;
-	
+
 	async_msg_1(exch, KBDEV_SET_IND, mods);
 	async_exchange_end(exch);
Index: uspace/srv/hid/input/generic/input.c
===================================================================
--- uspace/srv/hid/input/generic/input.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/input/generic/input.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -662,7 +662,7 @@
 	async_set_client_connection(client_connection);
 	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register server\n", NAME);
-		return rc;
+	if (rc < 0) {
+		printf("%s: Unable to register server (%d)\n", NAME, rc);
+		return -1;
 	}
 	
@@ -671,8 +671,7 @@
 	
 	service_id_t service_id;
-	rc = loc_service_register(kbd, &service_id);
-	if (rc != EOK) {
+	if (loc_service_register(kbd, &service_id) != EOK) {
 		printf("%s: Unable to register service %s\n", NAME, kbd);
-		return rc;
+		return -1;
 	}
 	
Index: uspace/srv/hid/input/port/adb.c
===================================================================
--- uspace/srv/hid/input/port/adb.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/input/port/adb.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -65,9 +65,12 @@
 static int adb_port_init(kbd_dev_t *kdev)
 {
+	const char *dev = "adb/kbd";
+	service_id_t service_id;
+	async_exch_t *exch;
+	int rc;
+	
 	kbd_dev = kdev;
 	
-	const char *dev = "adb/kbd";
-	service_id_t service_id;
-	int rc = loc_service_get_id(dev, &service_id, 0);
+	rc = loc_service_get_id(dev, &service_id, 0);
 	if (rc != EOK)
 		return rc;
@@ -79,5 +82,5 @@
 	}
 	
-	async_exch_t *exch = async_exchange_begin(dev_sess);
+	exch = async_exchange_begin(dev_sess);
 	if (exch == NULL) {
 		printf("%s: Failed starting exchange with device\n", NAME);
@@ -86,4 +89,5 @@
 	}
 	
+	/* NB: The callback connection is slotted for removal */
 	rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
 	async_exchange_end(exch);
Index: uspace/srv/hid/input/proto/mousedev.c
===================================================================
--- uspace/srv/hid/input/proto/mousedev.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/input/proto/mousedev.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -117,5 +117,5 @@
 		printf("%s: Failed starting session with '%s'\n", NAME,
 		    mdev->svc_name);
-		return ENOENT;
+		return -1;
 	}
 	
@@ -125,5 +125,5 @@
 		    NAME, mdev->svc_name);
 		async_hangup(sess);
-		return ENOMEM;
+		return -1;
 	}
 	
@@ -134,5 +134,5 @@
 		mousedev_destroy(mousedev);
 		async_hangup(sess);
-		return ENOENT;
+		return -1;
 	}
 	
@@ -145,8 +145,8 @@
 		    NAME, mdev->svc_name);
 		mousedev_destroy(mousedev);
-		return rc;
+		return -1;
 	}
 	
-	return EOK;
+	return 0;
 }
 
Index: uspace/srv/hid/remcons/remcons.c
===================================================================
--- uspace/srv/hid/remcons/remcons.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/remcons/remcons.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -71,5 +71,4 @@
 	TELNET_IAC, TELNET_WONT, TELNET_LINEMODE
 };
-
 static const size_t telnet_force_character_mode_command_count =
     sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t);
@@ -273,7 +272,8 @@
 static int network_user_fibril(void *arg)
 {
+	int rc;
 	telnet_user_t *user = arg;
 
-	int rc = loc_service_register(user->service_name, &user->service_id);
+	rc = loc_service_register(user->service_name, &user->service_id);
 	if (rc != EOK) {
 		telnet_user_error(user, "Unable to register %s with loc: %s.",
@@ -284,9 +284,9 @@
 	telnet_user_log(user, "Service %s registerd with id %" PRIun ".",
 	    user->service_name, user->service_id);
-	
+
 	fid_t spawn_fibril = fibril_create(spawn_task_fibril, user);
 	assert(spawn_fibril);
 	fibril_add_ready(spawn_fibril);
-	
+
 	/* Wait for all clients to exit. */
 	fibril_mutex_lock(&user->guard);
@@ -304,5 +304,5 @@
 	}
 	fibril_mutex_unlock(&user->guard);
-	
+
 	rc = loc_service_unregister(user->service_id);
 	if (rc != EOK) {
@@ -324,14 +324,15 @@
 	async_set_client_connection(client_connection);
 	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		fprintf(stderr, "%s: Unable to register server\n", NAME);
-		return rc;
-	}
-	
+	if (rc < 0) {
+		fprintf(stderr, NAME ": Unable to register server: %s.\n",
+		    str_error(rc));
+		return 1;
+	}
+
 	struct sockaddr_in addr;
-	
+
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons(port);
-	
+
 	rc = inet_pton(AF_INET, "127.0.0.1", (void *)
 	    &addr.sin_addr.s_addr);
Index: uspace/srv/hid/remcons/telnet.h
===================================================================
--- uspace/srv/hid/remcons/telnet.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/remcons/telnet.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -57,4 +57,5 @@
 #define TELNET_LINEMODE 34
 
+
 #endif
 
Index: uspace/srv/hid/remcons/user.h
===================================================================
--- uspace/srv/hid/remcons/user.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/remcons/user.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -76,26 +76,24 @@
 } telnet_user_t;
 
-extern telnet_user_t *telnet_user_create(int);
-extern void telnet_user_destroy(telnet_user_t *);
-extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t);
-extern bool telnet_user_is_zombie(telnet_user_t *);
-extern void telnet_user_notify_client_disconnected(telnet_user_t *);
-extern int telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *);
-extern int telnet_user_send_data(telnet_user_t *, uint8_t *, size_t);
-extern void telnet_user_update_cursor_x(telnet_user_t *, int);
+telnet_user_t *telnet_user_create(int socket);
+void telnet_user_destroy(telnet_user_t *user);
+telnet_user_t *telnet_user_get_for_client_connection(service_id_t id);
+bool telnet_user_is_zombie(telnet_user_t *user);
+void telnet_user_notify_client_disconnected(telnet_user_t *user);
+int telnet_user_get_next_keyboard_event(telnet_user_t *user, kbd_event_t *event);
+int telnet_user_send_data(telnet_user_t *user, uint8_t *data, size_t size);
+void telnet_user_update_cursor_x(telnet_user_t *user, int new_x);
 
 /** Print informational message about connected user. */
 #ifdef CONFIG_DEBUG
 #define telnet_user_log(user, fmt, ...) \
-	printf(NAME " [console %d (%d)]: " fmt "\n", \
-	    user->id, (int) user->service_id, ##__VA_ARGS__)
+	printf(NAME " [console %d (%d)]: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__)
 #else
-#define telnet_user_log(user, fmt, ...) ((void) 0)
+#define telnet_user_log(user, fmt, ...) (void)0
 #endif
 
 /** Print error message associated with connected user. */
 #define telnet_user_error(user, fmt, ...) \
-	fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \
-	    user->id, (int) user->service_id, ##__VA_ARGS__)
+	fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__)
 
 #endif
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -84,11 +84,13 @@
 int main(int argc, char *argv[])
 {
-	printf("%s: S3C24xx touchscreen driver\n", NAME);
+	int rc;
+
+	printf(NAME ": S3C24xx touchscreen driver\n");
 	
 	async_set_client_connection(s3c24xx_ts_connection);
-	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register driver.\n", NAME);
-		return rc;
+	rc = loc_server_register(NAME);
+	if (rc < 0) {
+		printf(NAME ": Unable to register driver.\n");
+		return -1;
 	}
 
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -77,11 +77,13 @@
 int main(int argc, char *argv[])
 {
-	printf("%s: S3C24xx on-chip UART driver\n", NAME);
-	
+	int rc;
+
+	printf(NAME ": S3C24xx on-chip UART driver\n");
+
 	async_set_client_connection(s3c24xx_uart_connection);
-	int rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf("%s: Unable to register server.\n", NAME);
-		return rc;
+	rc = loc_server_register(NAME);
+	if (rc < 0) {
+		printf(NAME ": Unable to register server.\n");
+		return -1;
 	}
 
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/loader/main.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -450,10 +450,9 @@
 	int rc = ns_intro(id);
 	if (rc != EOK)
-		return rc;
+		return -1;
 	
 	/* Register at naming service. */
-	rc = service_register(SERVICE_LOAD);
-	if (rc != EOK)
-		return rc;
+	if (service_register(SERVICE_LOAD) != EOK)
+		return -2;
 	
 	async_manager();
Index: uspace/srv/locsrv/locsrv.c
===================================================================
--- uspace/srv/locsrv/locsrv.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/locsrv/locsrv.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -390,4 +390,5 @@
 	 */
 	list_initialize(&server->services);
+
 	link_initialize(&server->servers);
 	
@@ -650,50 +651,4 @@
 	    min(size, act_size));
 	free(fqn);
-	
-	fibril_mutex_unlock(&services_list_mutex);
-	
-	async_answer_0(iid, retval);
-}
-
-static void loc_service_get_server_name(ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipc_callid_t callid;
-	size_t size;
-	size_t act_size;
-	loc_service_t *svc;
-	
-	if (!async_data_read_receive(&callid, &size)) {
-		async_answer_0(callid, EREFUSED);
-		async_answer_0(iid, EREFUSED);
-		return;
-	}
-	
-	fibril_mutex_lock(&services_list_mutex);
-	
-	svc = loc_service_find_id(IPC_GET_ARG1(*icall));
-	if (svc == NULL) {
-		fibril_mutex_unlock(&services_list_mutex);
-		async_answer_0(callid, ENOENT);
-		async_answer_0(iid, ENOENT);
-		return;
-	}
-	
-	if (svc->server == NULL) {
-		fibril_mutex_unlock(&services_list_mutex);
-		async_answer_0(callid, EINVAL);
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	act_size = str_size(svc->server->name);
-	if (act_size > size) {
-		fibril_mutex_unlock(&services_list_mutex);
-		async_answer_0(callid, EOVERFLOW);
-		async_answer_0(iid, EOVERFLOW);
-		return;
-	}
-	
-	sysarg_t retval = async_data_read_finalize(callid, svc->server->name,
-	    min(size, act_size));
 	
 	fibril_mutex_unlock(&services_list_mutex);
@@ -1451,7 +1406,4 @@
 			loc_service_get_name(callid, &call);
 			break;
-		case LOC_SERVICE_GET_SERVER_NAME:
-			loc_service_get_server_name(callid, &call);
-			break;
 		case LOC_NAMESPACE_GET_ID:
 			loc_namespace_get_id(callid, &call);
@@ -1538,7 +1490,6 @@
 	
 	/* Register location service at naming service */
-	int rc = service_register(SERVICE_LOC);
-	if (rc != EOK)
-		return rc;
+	if (service_register(SERVICE_LOC) != EOK)
+		return -1;
 	
 	printf("%s: Accepting connections\n", NAME);
Index: uspace/srv/locsrv/locsrv.h
===================================================================
--- uspace/srv/locsrv/locsrv.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/locsrv/locsrv.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -86,26 +86,18 @@
 	/** Link to global list of services (services_list) */
 	link_t services;
-	
 	/** Link to server list of services (loc_server_t.services) */
 	link_t server_services;
-	
 	/** Link to list of services in category (category_t.services) */
 	link_t cat_services;
-	
 	/** List of category memberships (svc_categ_t) */
 	list_t cat_memb;
-	
 	/** Unique service identifier */
 	service_id_t id;
-	
 	/** Service namespace */
 	loc_namespace_t *namespace;
-	
 	/** Service name */
 	char *name;
-	
 	/** Supplier of this service */
 	loc_server_t *server;
-	
 	/** Use this interface when forwarding to server. */
 	sysarg_t forward_interface;
Index: uspace/srv/net/ethip/ethip.c
===================================================================
--- uspace/srv/net/ethip/ethip.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/ethip/ethip.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -73,16 +73,18 @@
 static int ethip_init(void)
 {
+	int rc;
+
 	async_set_client_connection(ethip_client_conn);
-	
-	int rc = loc_server_register(NAME);
+
+	rc = loc_server_register(NAME);
 	if (rc != EOK) {
 		log_msg(LVL_ERROR, "Failed registering server.");
 		return rc;
 	}
-	
+
 	rc = ethip_nic_discovery_start();
 	if (rc != EOK)
 		return rc;
-	
+
 	return EOK;
 }
Index: uspace/srv/net/ethip/ethip_nic.c
===================================================================
--- uspace/srv/net/ethip/ethip_nic.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/ethip/ethip_nic.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -150,18 +150,20 @@
 static int ethip_nic_open(service_id_t sid)
 {
+	ethip_nic_t *nic;
+	int rc;
 	bool in_list = false;
 	nic_address_t nic_address;
-	
+
 	log_msg(LVL_DEBUG, "ethip_nic_open()");
-	ethip_nic_t *nic = ethip_nic_new();
+	nic = ethip_nic_new();
 	if (nic == NULL)
 		return ENOMEM;
-	
-	int rc = loc_service_get_name(sid, &nic->svc_name);
+
+	rc = loc_service_get_name(sid, &nic->svc_name);
 	if (rc != EOK) {
 		log_msg(LVL_ERROR, "Failed getting service name.");
 		goto error;
 	}
-	
+
 	nic->sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
 	if (nic->sess == NULL) {
@@ -169,7 +171,7 @@
 		goto error;
 	}
-	
+
 	nic->svc_id = sid;
-	
+
 	rc = nic_callback_create(nic->sess, ethip_nic_cb_conn, nic);
 	if (rc != EOK) {
@@ -296,5 +298,7 @@
 int ethip_nic_discovery_start(void)
 {
-	int rc = loc_register_cat_change_cb(ethip_nic_cat_change_cb);
+	int rc;
+
+	rc = loc_register_cat_change_cb(ethip_nic_cat_change_cb);
 	if (rc != EOK) {
 		log_msg(LVL_ERROR, "Failed registering callback for NIC "
@@ -302,5 +306,5 @@
 		return rc;
 	}
-	
+
 	return ethip_nic_check_new();
 }
Index: uspace/srv/net/inetsrv/inetsrv.c
===================================================================
--- uspace/srv/net/inetsrv/inetsrv.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/inetsrv/inetsrv.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -66,15 +66,17 @@
 static int inet_init(void)
 {
+	service_id_t sid;
+	int rc;
+
 	log_msg(LVL_DEBUG, "inet_init()");
-	
+
 	async_set_client_connection(inet_client_conn);
-	
-	int rc = loc_server_register(NAME);
+
+	rc = loc_server_register(NAME);
 	if (rc != EOK) {
 		log_msg(LVL_ERROR, "Failed registering server (%d).", rc);
 		return EEXIST;
 	}
-	
-	service_id_t sid;
+
 	rc = loc_service_register_with_iface(SERVICE_NAME_INET, &sid,
 	    INET_PORT_DEFAULT);
@@ -83,5 +85,5 @@
 		return EEXIST;
 	}
-	
+
 	rc = loc_service_register_with_iface(SERVICE_NAME_INETCFG, &sid,
 	    INET_PORT_CFG);
@@ -90,5 +92,5 @@
 		return EEXIST;
 	}
-	
+
 	rc = loc_service_register_with_iface(SERVICE_NAME_INETPING, &sid,
 	    INET_PORT_PING);
@@ -97,9 +99,9 @@
 		return EEXIST;
 	}
-	
+
 	rc = inet_link_discovery_start();
 	if (rc != EOK)
 		return EEXIST;
-	
+
 	return EOK;
 }
Index: uspace/srv/net/loopip/loopip.c
===================================================================
--- uspace/srv/net/loopip/loopip.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/loopip/loopip.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -91,7 +91,7 @@
 	category_id_t iplink_cat;
 	const char *svc_name = "net/loopback";
-	
+
 	async_set_client_connection(loopip_client_conn);
-	
+
 	rc = loc_server_register(NAME);
 	if (rc != EOK) {
Index: uspace/srv/net/tcp/sock.c
===================================================================
--- uspace/srv/net/tcp/sock.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/tcp/sock.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -68,12 +68,14 @@
 int tcp_sock_init(void)
 {
+	int rc;
+
 	socket_ports_initialize(&gsock);
-	
+
 	async_set_client_connection(tcp_sock_connection);
-	
-	int rc = service_register(SERVICE_TCP);
+
+	rc = service_register(SERVICE_TCP);
 	if (rc != EOK)
 		return EEXIST;
-	
+
 	return EOK;
 }
@@ -151,9 +153,6 @@
 	    sock, sock_id);
 
-	if (rc != EOK) {
-		fibril_destroy(sock->recv_fibril);
-		sock->recv_fibril = 0;
+	if (rc != EOK)
 		return rc;
-	}
 
 	sock_core = socket_cores_find(&sock->client->sockets, *sock_id);
Index: uspace/srv/net/udp/sock.c
===================================================================
--- uspace/srv/net/udp/sock.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/udp/sock.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -51,4 +51,6 @@
 #include "ucall.h"
 
+#define FRAGMENT_SIZE 1024
+
 /** Free ports pool start. */
 #define UDP_FREE_PORTS_START		1025
@@ -61,16 +63,17 @@
 
 static void udp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
-static int udp_sock_recv_fibril(void *arg);
 
 int udp_sock_init(void)
 {
+	int rc;
+
 	socket_ports_initialize(&gsock);
-	
+
 	async_set_client_connection(udp_sock_connection);
-	
-	int rc = service_register(SERVICE_UDP);
+
+	rc = service_register(SERVICE_UDP);
 	if (rc != EOK)
 		return EEXIST;
-	
+
 	return EOK;
 }
@@ -81,7 +84,6 @@
 
 	socket = (udp_sockdata_t *)sock_core->specific_data;
-	(void)socket;
-
-	/* XXX We need to force the receive fibril to quit */
+	assert(socket->assoc != NULL);
+	udp_uc_destroy(socket->assoc);
 }
 
@@ -91,5 +93,5 @@
 	async_exch_t *exch = async_exchange_begin(sock_core->sess);
 	async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t)sock_core->socket_id,
-	    UDP_FRAGMENT_SIZE, 0, 0, 1);
+	    FRAGMENT_SIZE, 0, 0, 1);
 	async_exchange_end(exch);
 }
@@ -113,21 +115,9 @@
 	sock->client = client;
 
-	sock->recv_buffer_used = 0;
-	sock->recv_error = UDP_EOK;
-	fibril_mutex_initialize(&sock->recv_buffer_lock);
-	fibril_condvar_initialize(&sock->recv_buffer_cv);
-
 	rc = udp_uc_create(&sock->assoc);
 	if (rc != EOK) {
+		udp_uc_destroy(sock->assoc);
 		free(sock);
 		async_answer_0(callid, rc);
-		return;
-	}
-
-	sock->recv_fibril = fibril_create(udp_sock_recv_fibril, sock);
-	if (sock->recv_fibril == 0) {
-		udp_uc_destroy(sock->assoc);
-		free(sock);
-		async_answer_0(callid, ENOMEM);
 		return;
 	}
@@ -136,12 +126,7 @@
 	rc = socket_create(&client->sockets, client->sess, sock, &sock_id);
 	if (rc != EOK) {
-		fibril_destroy(sock->recv_fibril);
-		udp_uc_destroy(sock->assoc);
-		free(sock);
 		async_answer_0(callid, rc);
 		return;
 	}
-
-	fibril_add_ready(sock->recv_fibril);
 
 	sock_core = socket_cores_find(&client->sockets, sock_id);
@@ -151,5 +136,5 @@
 	SOCKET_SET_SOCKET_ID(answer, sock_id);
 
-	SOCKET_SET_DATA_FRAGMENT_SIZE(answer, UDP_FRAGMENT_SIZE);
+	SOCKET_SET_DATA_FRAGMENT_SIZE(answer, FRAGMENT_SIZE);
 	SOCKET_SET_HEADER_SIZE(answer, sizeof(udp_header_t));
 	async_answer_3(callid, EOK, IPC_GET_ARG1(answer),
@@ -222,4 +207,6 @@
 	}
 
+	udp_sock_notify_data(sock_core);
+
 	log_msg(LVL_DEBUG, " - success");
 	async_answer_0(callid, rc);
@@ -260,5 +247,5 @@
 	ipc_callid_t wcallid;
 	size_t length;
-	uint8_t buffer[UDP_FRAGMENT_SIZE];
+	uint8_t buffer[FRAGMENT_SIZE];
 	udp_error_t urc;
 	int rc;
@@ -307,4 +294,6 @@
 			goto out;
 		}
+
+		udp_sock_notify_data(sock_core);
 	}
 
@@ -343,6 +332,6 @@
 		}
 
-		if (length > UDP_FRAGMENT_SIZE)
-			length = UDP_FRAGMENT_SIZE;
+		if (length > FRAGMENT_SIZE)
+			length = FRAGMENT_SIZE;
 
 		rc = async_data_write_finalize(wcallid, buffer, length);
@@ -380,5 +369,5 @@
 	
 	IPC_SET_ARG1(answer, 0);
-	SOCKET_SET_DATA_FRAGMENT_SIZE(answer, UDP_FRAGMENT_SIZE);
+	SOCKET_SET_DATA_FRAGMENT_SIZE(answer, FRAGMENT_SIZE);
 	async_answer_2(callid, EOK, IPC_GET_ARG1(answer),
 	    IPC_GET_ARG2(answer));
@@ -399,8 +388,10 @@
 	ipc_call_t answer;
 	ipc_callid_t rcallid;
+	uint8_t buffer[FRAGMENT_SIZE];
 	size_t data_len;
+	xflags_t xflags;
 	udp_error_t urc;
+	struct sockaddr_in addr;
 	udp_sock_t rsock;
-	struct sockaddr_in addr;
 	int rc;
 
@@ -427,19 +418,7 @@
 	(void)flags;
 
-	log_msg(LVL_DEBUG, "udp_sock_recvfrom(): lock recv_buffer lock");
-	fibril_mutex_lock(&socket->recv_buffer_lock);
-	while (socket->recv_buffer_used == 0 && socket->recv_error == UDP_EOK) {
-		log_msg(LVL_DEBUG, "udp_sock_recvfrom(): wait for cv");
-		fibril_condvar_wait(&socket->recv_buffer_cv,
-		    &socket->recv_buffer_lock);
-	}
-
-	log_msg(LVL_DEBUG, "Got data in sock recv_buffer");
-
-	rsock = socket->recv_fsock;
-	data_len = socket->recv_buffer_used;
-	urc = socket->recv_error;
-
-	log_msg(LVL_DEBUG, "**** recv data_len=%zu", data_len);
+	urc = udp_uc_receive(socket->assoc, buffer, FRAGMENT_SIZE, &data_len,
+	    &xflags, &rsock);
+	log_msg(LVL_DEBUG, "**** udp_uc_receive done, data_len=%zu", data_len);
 
 	switch (urc) {
@@ -460,5 +439,4 @@
 	log_msg(LVL_DEBUG, "**** udp_uc_receive -> %d", rc);
 	if (rc != EOK) {
-		fibril_mutex_unlock(&socket->recv_buffer_lock);
 		fibril_mutex_unlock(&socket->lock);
 		async_answer_0(callid, rc);
@@ -474,5 +452,4 @@
 		log_msg(LVL_DEBUG, "addr read receive");
 		if (!async_data_read_receive(&rcallid, &addr_length)) {
-			fibril_mutex_unlock(&socket->recv_buffer_lock);
 			fibril_mutex_unlock(&socket->lock);
 			async_answer_0(callid, EINVAL);
@@ -486,5 +463,4 @@
 		rc = async_data_read_finalize(rcallid, &addr, addr_length);
 		if (rc != EOK) {
-			fibril_mutex_unlock(&socket->recv_buffer_lock);
 			fibril_mutex_unlock(&socket->lock);
 			async_answer_0(callid, EINVAL);
@@ -495,5 +471,4 @@
 	log_msg(LVL_DEBUG, "data read receive");
 	if (!async_data_read_receive(&rcallid, &length)) {
-		fibril_mutex_unlock(&socket->recv_buffer_lock);
 		fibril_mutex_unlock(&socket->lock);
 		async_answer_0(callid, EINVAL);
@@ -505,5 +480,5 @@
 
 	log_msg(LVL_DEBUG, "data read finalize");
-	rc = async_data_read_finalize(rcallid, socket->recv_buffer, length);
+	rc = async_data_read_finalize(rcallid, buffer, length);
 
 	if (length < data_len && rc == EOK)
@@ -516,9 +491,7 @@
 	async_answer_3(callid, EOK, IPC_GET_ARG1(answer),
 	    IPC_GET_ARG2(answer), IPC_GET_ARG3(answer));
-
-	socket->recv_buffer_used = 0;
-
-	fibril_condvar_broadcast(&socket->recv_buffer_cv);
-	fibril_mutex_unlock(&socket->recv_buffer_lock);
+	
+	/* Push one fragment notification to client's queue */
+	udp_sock_notify_data(sock_core);
 	fibril_mutex_unlock(&socket->lock);
 }
@@ -567,46 +540,4 @@
 }
 
-static int udp_sock_recv_fibril(void *arg)
-{
-	udp_sockdata_t *sock = (udp_sockdata_t *)arg;
-	udp_error_t urc;
-	xflags_t xflags;
-	size_t rcvd;
-
-	log_msg(LVL_DEBUG, "udp_sock_recv_fibril()");
-
-	while (true) {
-		log_msg(LVL_DEBUG, "[] wait for rcv buffer empty()");
-		fibril_mutex_lock(&sock->recv_buffer_lock);
-		while (sock->recv_buffer_used != 0) {
-			fibril_condvar_wait(&sock->recv_buffer_cv,
-			    &sock->recv_buffer_lock);
-		}
-
-		log_msg(LVL_DEBUG, "[] call udp_uc_receive()");
-		urc = udp_uc_receive(sock->assoc, sock->recv_buffer,
-		    UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock);
-		sock->recv_error = urc;
-
-		udp_sock_notify_data(sock->sock_core);
-
-		if (urc != UDP_EOK) {
-			fibril_condvar_broadcast(&sock->recv_buffer_cv);
-			fibril_mutex_unlock(&sock->recv_buffer_lock);
-			break;
-		}
-
-		log_msg(LVL_DEBUG, "[] got data - broadcast recv_buffer_cv");
-
-		sock->recv_buffer_used = rcvd;
-		fibril_mutex_unlock(&sock->recv_buffer_lock);
-		fibril_condvar_broadcast(&sock->recv_buffer_cv);
-	}
-
-	udp_uc_destroy(sock->assoc);
-
-	return 0;
-}
-
 static void udp_sock_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
Index: uspace/srv/net/udp/udp.c
===================================================================
--- uspace/srv/net/udp/udp.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/udp/udp.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -73,5 +73,5 @@
 	printf(NAME ": UDP (User Datagram Protocol) service\n");
 
-	rc = log_init(NAME, LVL_DEBUG);
+	rc = log_init(NAME, LVL_WARN);
 	if (rc != EOK) {
 		printf(NAME ": Failed to initialize log.\n");
Index: uspace/srv/net/udp/udp_type.h
===================================================================
--- uspace/srv/net/udp/udp_type.h	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/net/udp/udp_type.h	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -36,11 +36,7 @@
 #define UDP_TYPE_H
 
-#include <fibril.h>
 #include <fibril_synch.h>
 #include <socket_core.h>
 #include <sys/types.h>
-
-#define UDP_FRAGMENT_SIZE 4096
-
 
 typedef enum {
@@ -145,12 +141,4 @@
 	/** Connection */
 	udp_assoc_t *assoc;
-	/** Receiving fibril */
-	fid_t recv_fibril;
-	uint8_t recv_buffer[UDP_FRAGMENT_SIZE];
-	size_t recv_buffer_used;
-	udp_sock_t recv_fsock;
-	fibril_mutex_t recv_buffer_lock;
-	fibril_condvar_t recv_buffer_cv;
-	udp_error_t recv_error;
 } udp_sockdata_t;
 
Index: uspace/srv/ns/ns.c
===================================================================
--- uspace/srv/ns/ns.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/ns/ns.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -48,5 +48,5 @@
 int main(int argc, char **argv)
 {
-	printf("%s: HelenOS IPC Naming Service\n", NAME);
+	printf(NAME ": HelenOS IPC Naming Service\n");
 	
 	int rc = service_init();
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision b4ca0a9c7a4302dc4ff22c5f6fc9f5a94a0ee3b2)
+++ uspace/srv/vfs/vfs.c	(revision a33706e404ea2be7e77e6260726d276e79b390f8)
@@ -159,5 +159,5 @@
 int main(int argc, char **argv)
 {
-	printf("%s: HelenOS VFS server\n", NAME);
+	printf(NAME ": HelenOS VFS server\n");
 	
 	/*
@@ -165,6 +165,5 @@
 	 */
 	if (!vfs_nodes_init()) {
-		printf("%s: Failed to initialize VFS node hash table\n",
-		    NAME);
+		printf(NAME ": Failed to initialize VFS node hash table\n");
 		return ENOMEM;
 	}
@@ -173,8 +172,8 @@
 	 * Allocate and initialize the Path Lookup Buffer.
 	 */
-	plb = as_area_create(AS_AREA_ANY, PLB_SIZE,
+	plb = as_area_create((void *) -1, PLB_SIZE,
 	    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
-	if (plb == AS_MAP_FAILED) {
-		printf("%s: Cannot create address space area\n", NAME);
+	if (plb == (void *) -1) {
+		printf(NAME ": Cannot create address space area\n");
 		return ENOMEM;
 	}
@@ -197,12 +196,11 @@
 	async_set_interrupt_received(notification_received);
 	event_task_subscribe(EVENT_TASK_STATE_CHANGE, VFS_TASK_STATE_CHANGE);
-	
+
 	/*
 	 * Register at the naming service.
 	 */
-	int rc = service_register(SERVICE_VFS);
-	if (rc != EOK) {
+	if (service_register(SERVICE_VFS) != EOK) {
 		printf("%s: Cannot register VFS service\n", NAME);
-		return rc;
+		return EINVAL;
 	}
 	
@@ -210,5 +208,5 @@
 	 * Start accepting connections.
 	 */
-	printf("%s: Accepting connections\n", NAME);
+	printf(NAME ": Accepting connections\n");
 	async_manager();
 	return 0;
