Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision 70ac8d0fbe40bd7d5685450882da3c93ffb7a479)
+++ libcfa/src/concurrency/kernel.cfa	(revision 2f1cb37bbca682c8066863a17e45b10acebc9c4c)
@@ -120,5 +120,5 @@
 static void __run_thread(processor * this, $thread * dst);
 static $thread * __halt(processor * this);
-static bool __wake_one(cluster * cltr, bool was_empty);
+static bool __wake_one(cluster * cltr);
 static bool __wake_proc(processor *);
 
@@ -197,5 +197,6 @@
 	self_mon.recursion = 1;
 	self_mon_p = &self_mon;
-	next = 0p;
+	link.next = 0p;
+	link.prev = 0p;
 
 	node.next = 0p;
@@ -223,4 +224,5 @@
 	this.name = name;
 	this.cltr = &cltr;
+	id = -1u;
 	terminated{ 0 };
 	destroyer = 0p;
@@ -260,5 +262,5 @@
 	this.preemption_rate = preemption_rate;
 	ready_queue{};
-	ready_queue_lock{};
+	ready_lock{};
 
 	#if !defined(__CFA_NO_STATISTICS__)
@@ -295,4 +297,10 @@
 	__cfadbg_print_safe(runtime_core, "Kernel : core %p starting\n", this);
 
+	// register the processor unless it's the main thread which is handled in the boot sequence
+	if(this != mainProcessor) {
+		this->id = doregister2(this->cltr, this);
+		ready_queue_grow( this->cltr );
+	}
+
 	doregister(this->cltr, this);
 
@@ -318,5 +326,5 @@
 				/* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
 				/* paranoid */ verifyf( readyThread->state == Ready || readyThread->preempted != __NO_PREEMPTION, "state : %d, preempted %d\n", readyThread->state, readyThread->preempted);
-				/* paranoid */ verifyf( readyThread->next == 0p, "Expected null got %p", readyThread->next );
+				/* paranoid */ verifyf( readyThread->link.next == 0p, "Expected null got %p", readyThread->link.next );
 
 				// We found a thread run it
@@ -334,10 +342,19 @@
 	V( this->terminated );
 
+	// unregister the processor unless it's the main thread which is handled in the boot sequence
+	if(this != mainProcessor) {
+		ready_queue_shrink( this->cltr );
+		unregister2(this->cltr, this);
+	}
+	else {
+		// HACK : the coroutine context switch expects this_thread to be set
+		// and it make sense for it to be set in all other cases except here
+		// fake it
+		kernelTLS.this_thread = mainThread;
+	}
+
 	__cfadbg_print_safe(runtime_core, "Kernel : core %p terminated\n", this);
 
-	// HACK : the coroutine context switch expects this_thread to be set
-	// and it make sense for it to be set in all other cases except here
-	// fake it
-	if( this == mainProcessor ) kernelTLS.this_thread = mainThread;
+	stats_tls_tally(this->cltr);
 }
 
@@ -591,22 +608,23 @@
 // Scheduler routines
 // KERNEL ONLY
-void __schedule_thread( $thread * thrd ) with( *thrd->curr_cluster ) {
+void __schedule_thread( $thread * thrd ) {
+	/* paranoid */ verify( thrd );
+	/* paranoid */ verify( thrd->state != Halted );
 	/* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
 	/* paranoid */ #if defined( __CFA_WITH_VERIFY__ )
-	/* paranoid */ if( thrd->state == Blocked || thrd->state == Start ) assertf( thrd->preempted == __NO_PREEMPTION,
-	                  "Error inactive thread marked as preempted, state %d, preemption %d\n", thrd->state, thrd->preempted );
-	/* paranoid */ if( thrd->preempted != __NO_PREEMPTION ) assertf(thrd->state == Active || thrd->state == Rerun,
-	                  "Error preempted thread marked as not currently running, state %d, preemption %d\n", thrd->state, thrd->preempted );
+	/* paranoid */ 	if( thrd->state == Blocked || thrd->state == Start ) assertf( thrd->preempted == __NO_PREEMPTION,
+					"Error inactive thread marked as preempted, state %d, preemption %d\n", thrd->state, thrd->preempted );
+	/* paranoid */ 	if( thrd->preempted != __NO_PREEMPTION ) assertf(thrd->state == Active || thrd->state == Rerun,
+					"Error preempted thread marked as not currently running, state %d, preemption %d\n", thrd->state, thrd->preempted );
 	/* paranoid */ #endif
-	/* paranoid */ verifyf( thrd->next == 0p, "Expected null got %p", thrd->next );
+	/* paranoid */ verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next );
 
 	if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
 
-	lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
-	bool was_empty = !(ready_queue != 0);
-	append( ready_queue, thrd );
-	unlock( ready_queue_lock );
-
-	__wake_one(thrd->curr_cluster, was_empty);
+	ready_schedule_lock(thrd->curr_cluster, kernelTLS.this_processor);
+		push( thrd->curr_cluster, thrd );
+
+		__wake_one(thrd->curr_cluster);
+	ready_schedule_unlock(thrd->curr_cluster, kernelTLS.this_processor);
 
 	/* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
@@ -617,7 +635,7 @@
 	/* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
 
-	lock( ready_queue_lock __cfaabi_dbg_ctx2 );
-	$thread * head = pop_head( ready_queue );
-	unlock( ready_queue_lock );
+	ready_schedule_lock(this, kernelTLS.this_processor);
+		$thread * head = pop( this );
+	ready_schedule_unlock(this, kernelTLS.this_processor);
 
 	/* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
@@ -703,5 +721,5 @@
 	// If that is the case, abandon the preemption.
 	bool preempted = false;
-	if(thrd->next == 0p) {
+	if(thrd->link.next == 0p) {
 		preempted = true;
 		thrd->preempted = reason;
@@ -763,4 +781,5 @@
 		pending_preemption = false;
 		kernel_thread = pthread_self();
+		id = -1u;
 
 		runner{ &this };
@@ -772,4 +791,6 @@
 	mainProcessor = (processor *)&storage_mainProcessor;
 	(*mainProcessor){};
+
+	mainProcessor->id = doregister2(mainCluster, mainProcessor);
 
 	//initialize the global state variables
@@ -826,8 +847,11 @@
 	kernel_stop_preemption();
 
+	unregister2(mainCluster, mainProcessor);
+
 	// Destroy the main processor and its context in reverse order of construction
 	// These were manually constructed so we need manually destroy them
 	void ^?{}(processor & this) with( this ){
 		/* paranoid */ verify( this.do_terminate == true );
+		__cfaabi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner);
 	}
 
@@ -835,4 +859,5 @@
 
 	// Final step, destroy the main thread since it is no longer needed
+
 	// Since we provided a stack to this taxk it will not destroy anything
 	/* paranoid */ verify(mainThread->self_cor.stack.storage == (__stack_t*)(((uintptr_t)&storage_mainThreadCtx)| 0x1));
@@ -887,8 +912,5 @@
 
 // Wake a thread from the front if there are any
-static bool __wake_one(cluster * this, __attribute__((unused)) bool force) {
-	// if we don't want to force check if we know it's false
-	// if( !this->idles.head && !force ) return false;
-
+static bool __wake_one(cluster * this) {
 	// First, lock the cluster idle
 	lock( this->idle_lock __cfaabi_dbg_ctx2 );
