Index: kernel/arch/ia64/src/drivers/ski.c
===================================================================
--- kernel/arch/ia64/src/drivers/ski.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/arch/ia64/src/drivers/ski.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -150,6 +150,6 @@
 	
 	if (instance) {
-		instance->thread = thread_create(kskipoll, instance, TASK, 0,
-		    "kskipoll", true);
+		instance->thread = thread_create(kskipoll, instance, TASK,
+		    THREAD_FLAG_UNCOUNTED, "kskipoll");
 		
 		if (!instance->thread) {
Index: kernel/arch/sparc64/src/drivers/niagara.c
===================================================================
--- kernel/arch/sparc64/src/drivers/niagara.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/arch/sparc64/src/drivers/niagara.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -184,6 +184,6 @@
 	
 	instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC);
-	instance->thread = thread_create(kniagarapoll, NULL, TASK, 0,
-	    "kniagarapoll", true);
+	instance->thread = thread_create(kniagarapoll, NULL, TASK,
+	    THREAD_FLAG_UNCOUNTED, "kniagarapoll");
 	
 	if (!instance->thread) {
Index: kernel/arch/sparc64/src/proc/sun4u/scheduler.c
===================================================================
--- kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/arch/sparc64/src/proc/sun4u/scheduler.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -51,5 +51,5 @@
 void before_thread_runs_arch(void)
 {
-	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
+	if (THREAD->uspace) {
 		/*
 		 * Write kernel stack address to %g6 of the alternate and
@@ -74,6 +74,6 @@
 void after_thread_ran_arch(void)
 {
-	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
-		/* sample the state of the userspace window buffer */	
+	if (THREAD->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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/arch/sparc64/src/proc/sun4v/scheduler.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -54,5 +54,5 @@
 void before_thread_runs_arch(void)
 {
-	if ((THREAD->flags & THREAD_FLAG_USPACE)) {
+	if (THREAD->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->flags & THREAD_FLAG_USPACE)) {
-		/* sample the state of the userspace window buffer */	
+	if (THREAD->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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/arch/sparc64/src/proc/thread.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -61,5 +61,5 @@
 void thread_create_arch(thread_t *t)
 {
-	if ((t->flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer))
+	if ((t->uspace) && (!t->arch.uspace_window_buffer))
 		{
 		/*
Index: kernel/genarch/src/kbrd/kbrd.c
===================================================================
--- kernel/genarch/src/kbrd/kbrd.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/genarch/src/kbrd/kbrd.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -158,6 +158,6 @@
 	    = malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC);
 	if (instance) {
-		instance->thread
-			= thread_create(kkbrd, (void *) instance, TASK, 0, "kkbrd", false);
+		instance->thread = thread_create(kkbrd, (void *) instance,
+		    TASK, THREAD_FLAG_NONE, "kkbrd");
 		
 		if (!instance->thread) {
Index: kernel/genarch/src/mm/as_ht.c
===================================================================
--- kernel/genarch/src/mm/as_ht.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/genarch/src/mm/as_ht.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -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_cache", sizeof(pte_t), 0, NULL, NULL,
-		    SLAB_CACHE_MAGDEFERRED);
+		pte_cache = slab_cache_create("pte_t", sizeof(pte_t), 0,
+		    NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 	}
 	
Index: kernel/genarch/src/srln/srln.c
===================================================================
--- kernel/genarch/src/srln/srln.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/genarch/src/srln/srln.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -130,6 +130,6 @@
 	    = malloc(sizeof(srln_instance_t), FRAME_ATOMIC);
 	if (instance) {
-		instance->thread
-			= thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false);
+		instance->thread = thread_create(ksrln, (void *) instance,
+		    TASK, THREAD_FLAG_NONE, "ksrln");
 		
 		if (!instance->thread) {
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/include/proc/thread.h	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -54,21 +54,13 @@
 
 /* Thread flags */
-
-/** 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)
+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 structure. There is one per thread. */
@@ -147,5 +139,5 @@
 	
 	fpu_context_t *saved_fpu_context;
-	int fpu_context_exists;
+	bool fpu_context_exists;
 	
 	/*
@@ -154,18 +146,22 @@
 	 * thread. This disables migration.
 	 */
-	int fpu_context_engaged;
+	bool fpu_context_engaged;
 	
 	/* The thread will not be migrated if nomigrate is non-zero. */
-	int nomigrate;
-	
-	/** Thread's state. */
+	unsigned int nomigrate;
+	
+	/** Thread state. */
 	state_t state;
-	/** Thread's flags. */
-	unsigned int flags;
-	
-	/** Thread's CPU. */
+	
+	/** Thread 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. */
@@ -216,5 +212,6 @@
 extern void thread_init(void);
 extern thread_t *thread_create(void (*)(void *), void *, task_t *,
-    unsigned int, const char *, bool);
+    thread_flags_t, const char *);
+extern void thread_wire(thread_t *, cpu_t *);
 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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/adt/btree.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -71,5 +71,5 @@
 void btree_init(void)
 {
-	btree_node_slab = slab_cache_create("btree_node_slab",
+	btree_node_slab = slab_cache_create("btree_node_t",
 	    sizeof(btree_node_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 }
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/console/cmd.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -724,11 +724,7 @@
 		thread_t *thread;
 		if ((thread = thread_create((void (*)(void *)) cmd_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);
-			
+		    (void *) argv, TASK, THREAD_FLAG_NONE, "call0"))) {
 			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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/ipc/ipc.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -670,7 +670,7 @@
 void ipc_init(void)
 {
-	ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
+	ipc_call_slab = slab_cache_create("call_t", sizeof(call_t), 0, NULL,
 	    NULL, 0);
-	ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
+	ipc_answerbox_slab = slab_cache_create("answerbox_t",
 	    sizeof(answerbox_t), 0, NULL, NULL, 0);
 }
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/ipc/kbox.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -244,6 +244,6 @@
 	
 	/* Create a kbox thread */
-	thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task, 0,
-	    "kbox", false);
+	thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
+	    THREAD_FLAG_NONE, "kbox");
 	if (!kb_thread) {
 		mutex_unlock(&task->kb.cleanup_lock);
Index: kernel/generic/src/lib/ra.c
===================================================================
--- kernel/generic/src/lib/ra.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/lib/ra.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -424,5 +424,5 @@
 void ra_init(void)
 {
-	ra_segment_cache = slab_cache_create("segment_cache",
+	ra_segment_cache = slab_cache_create("ra_segment_t",
 	    sizeof(ra_segment_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 }
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/main/kinit.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -116,9 +116,8 @@
 		 * Just a beautification.
 		 */
-		thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
+		thread = thread_create(kmp, NULL, TASK,
+		    THREAD_FLAG_UNCOUNTED, "kmp");
 		if (thread != NULL) {
-			irq_spinlock_lock(&thread->lock, false);
-			thread->cpu = &cpus[0];
-			irq_spinlock_unlock(&thread->lock, false);
+			thread_wire(thread, &cpus[0]);
 			thread_ready(thread);
 		} else
@@ -134,9 +133,8 @@
 		
 		for (i = 0; i < config.cpu_count; i++) {
-			thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
+			thread = thread_create(kcpulb, NULL, TASK,
+			    THREAD_FLAG_UNCOUNTED, "kcpulb");
 			if (thread != NULL) {
-				irq_spinlock_lock(&thread->lock, false);
-				thread->cpu = &cpus[i];
-				irq_spinlock_unlock(&thread->lock, false);
+				thread_wire(thread, &cpus[i]);
 				thread_ready(thread);
 			} else
@@ -152,5 +150,6 @@
 	
 	/* Start thread computing system load */
-	thread = thread_create(kload, NULL, TASK, 0, "kload", false);
+	thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
+	    "kload");
 	if (thread != NULL)
 		thread_ready(thread);
@@ -163,5 +162,6 @@
 		 * Create kernel console.
 		 */
-		thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false);
+		thread = thread_create(kconsole_thread, NULL, TASK,
+		    THREAD_FLAG_NONE, "kconsole");
 		if (thread != NULL)
 			thread_ready(thread);
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/main/main.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -276,6 +276,6 @@
 	 * Create the first thread.
 	 */
-	thread_t *kinit_thread =
-	    thread_create(kinit, NULL, kernel, 0, "kinit", true);
+	thread_t *kinit_thread = thread_create(kinit, NULL, kernel,
+	    THREAD_FLAG_UNCOUNTED, "kinit");
 	if (!kinit_thread)
 		panic("Cannot create kinit thread.");
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/mm/as.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -130,5 +130,5 @@
 	as_arch_init();
 	
-	as_slab = slab_cache_create("as_slab", sizeof(as_t), 0,
+	as_slab = slab_cache_create("as_t", sizeof(as_t), 0,
 	    as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
 	
Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/mm/slab.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -891,5 +891,5 @@
 {
 	/* Initialize magazine cache */
-	_slab_cache_create(&mag_cache, "slab_magazine",
+	_slab_cache_create(&mag_cache, "slab_magazine_t",
 	    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",
+	_slab_cache_create(&slab_cache_cache, "slab_cache_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_extern", sizeof(slab_t), 0,
+	slab_extern_cache = slab_cache_create("slab_t", sizeof(slab_t), 0,
 	    NULL, NULL, SLAB_CACHE_SLINSIDE | SLAB_CACHE_MAGDEFERRED);
 	
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/proc/program.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -102,5 +102,5 @@
 	 */
 	prg->main_thread = thread_create(uinit, kernel_uarg, prg->task,
-	    THREAD_FLAG_USPACE, "uinit", false);
+	    THREAD_FLAG_USPACE, "uinit");
 	if (!prg->main_thread) {
 		free(kernel_uarg);
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/proc/scheduler.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -98,5 +98,5 @@
 	else {
 		fpu_init();
-		THREAD->fpu_context_exists = 1;
+		THREAD->fpu_context_exists = true;
 	}
 #endif
@@ -142,5 +142,5 @@
 		
 		/* Don't prevent migration */
-		CPU->fpu_owner->fpu_context_engaged = 0;
+		CPU->fpu_owner->fpu_context_engaged = false;
 		irq_spinlock_unlock(&CPU->fpu_owner->lock, false);
 		CPU->fpu_owner = NULL;
@@ -163,9 +163,9 @@
 		}
 		fpu_init();
-		THREAD->fpu_context_exists = 1;
+		THREAD->fpu_context_exists = true;
 	}
 	
 	CPU->fpu_owner = THREAD;
-	THREAD->fpu_context_engaged = 1;
+	THREAD->fpu_context_engaged = true;
 	irq_spinlock_unlock(&THREAD->lock, false);
 	
@@ -248,8 +248,8 @@
 		
 		/*
-		 * Clear the THREAD_FLAG_STOLEN flag so that t can be migrated
+		 * Clear the stolen flag so that it can be migrated
 		 * when load balancing needs emerge.
 		 */
-		thread->flags &= ~THREAD_FLAG_STOLEN;
+		thread->stolen = false;
 		irq_spinlock_unlock(&thread->lock, false);
 		
@@ -630,8 +630,7 @@
 				irq_spinlock_lock(&thread->lock, false);
 				
-				if (!(thread->flags & THREAD_FLAG_WIRED) &&
-				    !(thread->flags & THREAD_FLAG_STOLEN) &&
-				    !thread->nomigrate &&
-				    !thread->fpu_context_engaged) {
+				if ((!thread->wired) && (!thread->stolen) &&
+				    (!thread->nomigrate) &&
+				    (!thread->fpu_context_engaged)) {
 					/*
 					 * Remove thread from ready queue.
@@ -670,5 +669,5 @@
 #endif
 				
-				thread->flags |= THREAD_FLAG_STOLEN;
+				thread->stolen = true;
 				thread->state = Entering;
 				
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/proc/task.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -90,5 +90,5 @@
 	TASK = NULL;
 	avltree_create(&tasks_tree);
-	task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,
+	task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
 	    tsk_constructor, NULL, 0);
 }
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/proc/thread.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -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_slab", sizeof(thread_t), 0,
+	thread_slab = slab_cache_create("thread_t", sizeof(thread_t), 0,
 	    thr_constructor, thr_destructor, 0);
 	
 #ifdef CONFIG_FPU
-	fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
-	    FPU_CONTEXT_ALIGN, NULL, NULL, 0);
+	fpu_context_slab = slab_cache_create("fpu_context_t",
+	    sizeof(fpu_context_t), FPU_CONTEXT_ALIGN, NULL, NULL, 0);
 #endif
 	
@@ -247,4 +247,17 @@
 }
 
+/** Wire thread to the given CPU
+ *
+ * @param cpu CPU to wire the thread to.
+ *
+ */
+void thread_wire(thread_t *thread, cpu_t *cpu)
+{
+	irq_spinlock_lock(&thread->lock, true);
+	thread->cpu = cpu;
+	thread->wired = true;
+	irq_spinlock_unlock(&thread->lock, true);
+}
+
 /** Make thread ready
  *
@@ -260,12 +273,14 @@
 	ASSERT(thread->state != Ready);
 	
-	int i = (thread->priority < RQ_COUNT - 1)
-	    ? ++thread->priority : thread->priority;
-	
-	cpu_t *cpu = CPU;
-	if (thread->flags & THREAD_FLAG_WIRED) {
+	int i = (thread->priority < RQ_COUNT - 1) ?
+	    ++thread->priority : thread->priority;
+	
+	cpu_t *cpu;
+	if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) {
 		ASSERT(thread->cpu != NULL);
 		cpu = thread->cpu;
-	}
+	} else
+		cpu = CPU;
+	
 	thread->state = Ready;
 	
@@ -298,6 +313,4 @@
  * @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.
@@ -305,5 +318,5 @@
  */
 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
-    unsigned int flags, const char *name, bool uncounted)
+    thread_flags_t flags, const char *name)
 {
 	thread_t *thread = (thread_t *) slab_alloc(thread_slab, 0);
@@ -335,8 +348,13 @@
 	thread->ucycles = 0;
 	thread->kcycles = 0;
-	thread->uncounted = uncounted;
+	thread->uncounted =
+	    ((flags & THREAD_FLAG_UNCOUNTED) == THREAD_FLAG_UNCOUNTED);
 	thread->priority = -1;          /* Start in rq[0] */
 	thread->cpu = NULL;
-	thread->flags = flags;
+	thread->wired = false;
+	thread->stolen = false;
+	thread->uspace =
+	    ((flags & THREAD_FLAG_USPACE) == THREAD_FLAG_USPACE);
+	
 	thread->nomigrate = 0;
 	thread->state = Entering;
@@ -356,6 +374,6 @@
 	thread->task = task;
 	
-	thread->fpu_context_exists = 0;
-	thread->fpu_context_engaged = 0;
+	thread->fpu_context_exists = false;
+	thread->fpu_context_engaged = false;
 	
 	avltree_node_initialize(&thread->threads_tree_node);
@@ -371,5 +389,5 @@
 	thread_create_arch(thread);
 	
-	if (!(flags & THREAD_FLAG_NOATTACH))
+	if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
 		thread_attach(thread, task);
 	
@@ -437,5 +455,5 @@
 	
 	/* Must not count kbox thread into lifecount */
-	if (thread->flags & THREAD_FLAG_USPACE)
+	if (thread->uspace)
 		atomic_inc(&task->lifecount);
 	
@@ -459,9 +477,9 @@
 void thread_exit(void)
 {
-	if (THREAD->flags & THREAD_FLAG_USPACE) {
+	if (THREAD->uspace) {
 #ifdef CONFIG_UDEBUG
 		/* Generate udebug THREAD_E event */
 		udebug_thread_e_event();
-
+		
 		/*
 		 * This thread will not execute any code or system calls from
@@ -506,5 +524,5 @@
 {
 	ASSERT(THREAD);
-
+	
 	THREAD->nomigrate++;
 }
@@ -515,6 +533,7 @@
 	ASSERT(THREAD);
 	ASSERT(THREAD->nomigrate > 0);
-
-	THREAD->nomigrate--;
+	
+	if (THREAD->nomigrate > 0)
+		THREAD->nomigrate--;
 }
 
@@ -865,5 +884,5 @@
 	
 	thread_t *thread = thread_create(uinit, kernel_uarg, TASK,
-	    THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf, false);
+	    THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf);
 	if (thread) {
 		if (uspace_thread_id != NULL) {
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -97,5 +97,5 @@
 void sysinfo_init(void)
 {
-	sysinfo_item_slab = slab_cache_create("sysinfo_item_slab",
+	sysinfo_item_slab = slab_cache_create("sysinfo_item_t",
 	    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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/udebug/udebug.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -410,8 +410,7 @@
 		
 		mutex_lock(&thread->udebug.lock);
-		unsigned int flags = thread->flags;
 		
 		/* Only process userspace threads. */
-		if ((flags & THREAD_FLAG_USPACE) != 0) {
+		if (thread->uspace) {
 			/* 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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -95,5 +95,5 @@
 	
 	/* Verify that 'thread' is a userspace thread. */
-	if ((thread->flags & THREAD_FLAG_USPACE) == 0) {
+	if (!thread->uspace) {
 		/* It's not, deny its existence */
 		irq_spinlock_unlock(&thread->lock, true);
@@ -200,5 +200,5 @@
 		
 		mutex_lock(&thread->udebug.lock);
-		if ((thread->flags & THREAD_FLAG_USPACE) != 0) {
+		if (thread->uspace) {
 			thread->udebug.active = true;
 			mutex_unlock(&thread->udebug.lock);
@@ -393,9 +393,9 @@
 		
 		irq_spinlock_lock(&thread->lock, false);
-		int flags = thread->flags;
+		bool uspace = thread->uspace;
 		irq_spinlock_unlock(&thread->lock, false);
 		
 		/* Not interested in kernel threads. */
-		if ((flags & THREAD_FLAG_USPACE) == 0)
+		if (!uspace)
 			continue;
 		
Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/mm/falloc1.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -37,32 +37,31 @@
 #include <align.h>
 
-#define MAX_FRAMES  1024
+#define MAX_FRAMES  1024U
 #define MAX_ORDER   8
 #define TEST_RUNS   2
 
-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;
-	
+const char *test_falloc1(void)
+{
 	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";
 	
-	for (run = 0; run < TEST_RUNS; run++) {
-		for (order = 0; order <= MAX_ORDER; order++) {
-			TPRINTF("Allocating %d frames blocks ... ", 1 << order);
+	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);
 			
-			allocated = 0;
-			for (i = 0; i < MAX_FRAMES >> order; i++) {
-				frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+			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);
 				
-				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
-					TPRINTF("Block at address %p (size %dK) is not aligned\n",
+				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) !=
+				    frames[allocated]) {
+					TPRINTF("Block at address %p (size %u) is not aligned\n",
 					    (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
 					return "Test failed";
@@ -87,5 +86,5 @@
 			TPRINTF("Deallocating ... ");
 			
-			for (i = 0; i < allocated; i++)
+			for (unsigned int i = 0; i < allocated; i++)
 				frame_free(KA2PA(frames[i]));
 			
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/mm/falloc2.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -40,5 +40,5 @@
 #include <arch.h>
 
-#define MAX_FRAMES  256
+#define MAX_FRAMES  256U
 #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,11 +65,14 @@
 	thread_detach(THREAD);
 	
-	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);
+	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);
 			
-			allocated = 0;
-			for (i = 0; i < (MAX_FRAMES >> order); i++) {
-				frames[allocated] = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
+			unsigned int allocated = 0;
+			for (unsigned int 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);
@@ -79,12 +82,18 @@
 			}
 			
-			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);
+			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);
 			
-			for (i = 0; i < allocated; i++) {
-				for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) {
+			for (unsigned int i = 0; i < allocated; i++) {
+				for (size_t 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;
@@ -94,5 +103,6 @@
 			}
 			
-			TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
+			TPRINTF("Thread #%" PRIu64 " (cpu%u): "
+			    "Finished run.\n", THREAD->tid, CPU->id);
 		}
 	}
@@ -101,5 +111,6 @@
 	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);
 }
@@ -107,11 +118,10 @@
 const char *test_falloc2(void)
 {
-	unsigned int i;
-	
 	atomic_set(&thread_count, THREADS);
 	atomic_set(&thread_fail, 0);
 	
-	for (i = 0; i < THREADS; i++) {
-		thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false);
+	for (unsigned int i = 0; i < THREADS; i++) {
+		thread_t *thrd = thread_create(falloc, NULL, TASK,
+		    THREAD_FLAG_NONE, "falloc2");
 		if (!thrd) {
 			TPRINTF("Could not create thread %u\n", i);
@@ -122,5 +132,6 @@
 	
 	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 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/mm/slab1.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -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, 0, "slabtest", false))) {
+	for (i = 0; i < THREADS; i++) {
+		if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) {
 			TPRINTF("Could not create thread %d\n", i);
 		} else
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/mm/slab2.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -52,6 +52,6 @@
 	void *olddata1 = NULL, *olddata2 = NULL;
 	
-	cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
-	cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
+	cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
+	cache2 = slab_cache_create("test_cache2", 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, 0, "slabtest", false))) {
+	for (i = 0; i < THREADS; i++) {
+		if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) {
 			TPRINTF("Could not create thread %d\n", i);
 		} else
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/synch/semaphore1.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -93,5 +93,6 @@
 		for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
 			for (k = 0; k < i; k++) {
-				thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
+				thrd = thread_create(consumer, NULL, TASK,
+				    THREAD_FLAG_NONE, "consumer");
 				if (thrd)
 					thread_ready(thrd);
@@ -100,5 +101,6 @@
 			}
 			for (k = 0; k < (4 - i); k++) {
-				thrd = thread_create(producer, NULL, TASK, 0, "producer", false);
+				thrd = thread_create(producer, NULL, TASK,
+				    THREAD_FLAG_NONE, "producer");
 				if (thrd)
 					thread_ready(thrd);
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/synch/semaphore2.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -93,5 +93,6 @@
 	TPRINTF("Creating %" PRIu32 " consumers\n", k);
 	for (i = 0; i < k; i++) {
-		thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
+		thrd = thread_create(consumer, NULL, TASK,
+		    THREAD_FLAG_NONE, "consumer");
 		if (thrd)
 			thread_ready(thrd);
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ kernel/test/thread/thread1.c	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -63,5 +63,6 @@
 	for (i = 0; i < THREADS; i++) {
 		thread_t *t;
-		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
+		if (!(t = thread_create(threadtest, NULL, TASK,
+		    THREAD_FLAG_NONE, "threadtest"))) {
 			TPRINTF("Could not create thread %d\n", i);
 			break;
Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision 79d74fe1b25225ae092e5828d6516b12c588cb80)
+++ tools/toolchain.sh	(revision 1f092d9ee54c991d7f2820ce325e6374d85b3a26)
@@ -55,5 +55,5 @@
 BINUTILS_VERSION="2.22"
 BINUTILS_RELEASE=""
-GCC_VERSION="4.7.0"
+GCC_VERSION="4.7.1"
 GDB_VERSION="7.4"
 
@@ -274,5 +274,5 @@
 	
 	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5"
-	download_fetch "${GCC_SOURCE}" "${GCC}" "2a0f1d99fda235c29d40b561f81d9a77"
+	download_fetch "${GCC_SOURCE}" "${GCC}" "933e6f15f51c031060af64a9e14149ff"
 	download_fetch "${GDB_SOURCE}" "${GDB}" "95a9a8305fed4d30a30a6dc28ff9d060"
 }
@@ -319,5 +319,5 @@
 	
 	change_title "binutils: configure (${PLATFORM})"
-	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls
+	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls --disable-werror
 	check_error $? "Error configuring binutils."
 	
@@ -331,5 +331,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
+	"${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
 	check_error $? "Error configuring GCC."
 	
