Index: kernel/arch/amd64/include/cpu.h
===================================================================
--- kernel/arch/amd64/include/cpu.h	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ kernel/arch/amd64/include/cpu.h	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -36,7 +36,14 @@
 #define KERN_amd64_CPU_H_
 
-#define RFLAGS_IF  (1 << 9)
-#define RFLAGS_DF  (1 << 10)
-#define RFLAGS_RF  (1 << 16)
+#define RFLAGS_CF	(1 << 0)
+#define RFLAGS_PF	(1 << 2)
+#define RFLAGS_AF	(1 << 4)
+#define RFLAGS_ZF	(1 << 6)
+#define RFLAGS_SF	(1 << 7)
+#define RFLAGS_TF	(1 << 8)
+#define RFLAGS_IF	(1 << 9)
+#define RFLAGS_DF	(1 << 10)
+#define RFLAGS_OF	(1 << 11)
+#define RFLAGS_RF	(1 << 16)
 
 #define EFER_MSR_NUM    0xc0000080
Index: kernel/arch/amd64/src/userspace.c
===================================================================
--- kernel/arch/amd64/src/userspace.c	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ kernel/arch/amd64/src/userspace.c	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -34,4 +34,5 @@
 
 #include <userspace.h>
+#include <arch/cpu.h>
 #include <arch/pm.h>
 #include <arch/types.h>
@@ -50,29 +51,30 @@
 	ipl_t ipl = interrupts_disable();
 	
-	/* Clear CF, PF, AF, ZF, SF, DF, OF */
-	ipl &= ~(0xcd4);
+	ipl &= ~(RFLAGS_CF | RFLAGS_PF | RFLAGS_AF | RFLAGS_ZF | RFLAGS_SF |
+	    RFLAGS_DF | RFLAGS_OF);
 	
 	asm volatile (
-			"pushq %[udata_des]\n"
-			"pushq %[stack_size]\n"
-			"pushq %[ipl]\n"
-			"pushq %[utext_des]\n"
-			"pushq %[entry]\n"
-			"movq %[uarg], %%rax\n"
+		"pushq %[udata_des]\n"
+		"pushq %[stack_size]\n"
+		"pushq %[ipl]\n"
+		"pushq %[utext_des]\n"
+		"pushq %[entry]\n"
+		"movq %[uarg], %%rax\n"
 			
-			/* %rdi is defined to hold pcb_ptr - set it to 0 */
-			"xorq %%rdi, %%rdi\n"
-			"iretq\n"
-			:: [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
-			   [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
-			   [ipl] "r" (ipl),
-			   [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
-			   [entry] "r" (kernel_uarg->uspace_entry),
-			   [uarg] "r" (kernel_uarg->uspace_uarg)
-			: "rax"
-		);
+		/* %rdi is defined to hold pcb_ptr - set it to 0 */
+		"xorq %%rdi, %%rdi\n"
+		"iretq\n"
+		:: [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
+		   [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
+		   [ipl] "r" (ipl),
+		   [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
+		   [entry] "r" (kernel_uarg->uspace_entry),
+		   [uarg] "r" (kernel_uarg->uspace_uarg)
+		: "rax"
+	);
 	
 	/* Unreachable */
-	while (1);
+	while (1)
+		;
 }
 
Index: kernel/arch/sparc64/src/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sparc64.c	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ kernel/arch/sparc64/src/sparc64.c	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -135,4 +135,5 @@
 void userspace(uspace_arg_t *kernel_uarg)
 {
+	(void) interrupts_disable();
 	switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
 	    ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE
Index: kernel/generic/src/main/uinit.c
===================================================================
--- kernel/generic/src/main/uinit.c	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ kernel/generic/src/main/uinit.c	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -81,11 +81,4 @@
 	free((uspace_arg_t *) arg);
 	
-	/*
-	 * Disable interrupts so that the execution of userspace() is not
-	 * disturbed by any interrupts as some of the userspace()
-	 * implementations will switch to the userspace stack before switching
-	 * the mode.
-	 */
-	(void) interrupts_disable();
 	userspace(&uarg);
 }
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ kernel/generic/src/proc/task.c	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -75,4 +75,7 @@
 static task_id_t task_counter = 0;
 
+/* Forward declarations. */
+static void task_kill_internal(task_t *);
+
 /** Initialize kernel tasks support. */
 void task_init(void)
@@ -83,5 +86,5 @@
 
 /*
- * The idea behind this walker is to remember a single task different from
+ * The idea behind this walker is to kill and count all tasks different from
  * TASK.
  */
@@ -89,9 +92,12 @@
 {
 	task_t *t = avltree_get_instance(node, task_t, tasks_tree_node);
-	task_t **tp = (task_t **) arg;
-
-	if (t != TASK) { 
-		*tp = t;
-		return false;	/* stop walking */
+	unsigned *cnt = (unsigned *) arg;
+
+	if (t != TASK) {
+		(*cnt)++;
+#ifdef CONFIG_DEBUG
+		printf("[%"PRIu64"] ", t->taskid);
+#endif
+		task_kill_internal(t);
 	}
 
@@ -102,31 +108,22 @@
 void task_done(void)
 {
-	task_t *t;
+	unsigned tasks_left;
+
 	do { /* Repeat until there are any tasks except TASK */
-		
 		/* Messing with task structures, avoid deadlock */
+#ifdef CONFIG_DEBUG
+		printf("Killing tasks... ");
+#endif
 		ipl_t ipl = interrupts_disable();
 		spinlock_lock(&tasks_lock);
-		
-		t = NULL;
-		avltree_walk(&tasks_tree, task_done_walker, &t);
-		
-		if (t != NULL) {
-			task_id_t id = t->taskid;
-			
-			spinlock_unlock(&tasks_lock);
-			interrupts_restore(ipl);
-			
+		tasks_left = 0;
+		avltree_walk(&tasks_tree, task_done_walker, &tasks_left);
+		spinlock_unlock(&tasks_lock);
+		interrupts_restore(ipl);
+		thread_sleep(1);
 #ifdef CONFIG_DEBUG
-			printf("Killing task %" PRIu64 "\n", id);
-#endif			
-			task_kill(id);
-			thread_usleep(10000);
-		} else {
-			spinlock_unlock(&tasks_lock);
-			interrupts_restore(ipl);
-		}
-		
-	} while (t != NULL);
+		printf("\n");
+#endif
+	} while (tasks_left);
 }
 
@@ -350,31 +347,8 @@
 }
 
-/** Kill task.
- *
- * This function is idempotent.
- * It signals all the task's threads to bail it out.
- *
- * @param id		ID of the task to be killed.
- *
- * @return		Zero on success or an error code from errno.h.
- */
-int task_kill(task_id_t id)
-{
-	ipl_t ipl;
-	task_t *ta;
+static void task_kill_internal(task_t *ta)
+{
 	link_t *cur;
 
-	if (id == 1)
-		return EPERM;
-	
-	ipl = interrupts_disable();
-	spinlock_lock(&tasks_lock);
-	if (!(ta = task_find_by_id(id))) {
-		spinlock_unlock(&tasks_lock);
-		interrupts_restore(ipl);
-		return ENOENT;
-	}
-	spinlock_unlock(&tasks_lock);
-	
 	/*
 	 * Interrupt all threads.
@@ -397,6 +371,33 @@
 	}
 	spinlock_unlock(&ta->lock);
+}
+
+/** Kill task.
+ *
+ * This function is idempotent.
+ * It signals all the task's threads to bail it out.
+ *
+ * @param id		ID of the task to be killed.
+ *
+ * @return		Zero on success or an error code from errno.h.
+ */
+int task_kill(task_id_t id)
+{
+	ipl_t ipl;
+	task_t *ta;
+
+	if (id == 1)
+		return EPERM;
+	
+	ipl = interrupts_disable();
+	spinlock_lock(&tasks_lock);
+	if (!(ta = task_find_by_id(id))) {
+		spinlock_unlock(&tasks_lock);
+		interrupts_restore(ipl);
+		return ENOENT;
+	}
+	task_kill_internal(ta);
+	spinlock_unlock(&tasks_lock);
 	interrupts_restore(ipl);
-	
 	return 0;
 }
Index: tools/config.py
===================================================================
--- tools/config.py	(revision a7de790748ceb032360357ea5a7335de42821d87)
+++ tools/config.py	(revision d5f8f19a37dee7c1b854afeae4b99ee5a38287a2)
@@ -225,5 +225,5 @@
 	"Create output configuration"
 	
-	revision = commands.getoutput('svnversion . 2> /dev/null')
+	revision = commands.getoutput('bzr version-info --custom --template="{revision_id}" 2> /dev/null')
 	timestamp = commands.getoutput('date "+%Y-%m-%d %H:%M:%S"')
 	
