Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision e8c52cf03237e8eb838f2de7d6a65626299a417b)
+++ libcfa/src/concurrency/kernel.cfa	(revision 39014579a68bf3e90d49ec9648e7f3f4a5c05b4f)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Nov 29 17:59:16 2019
-// Update Count     : 35
+// Last Modified On : Sun Dec  1 17:52:57 2019
+// Update Count     : 45
 //
 
@@ -41,5 +41,5 @@
 //-----------------------------------------------------------------------------
 // Some assembly required
-#if   defined( __i386 )
+#if defined( __i386 )
 	#define CtxGet( ctx )        \
 		__asm__ volatile (     \
@@ -124,5 +124,5 @@
 
 extern "C" {
-struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
+	struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
 }
 
@@ -132,5 +132,5 @@
 // Global state
 thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = {
-	NULL,
+	NULL,												// cannot use 0p
 	NULL,
 	{ NULL, 1, false, false },
@@ -141,8 +141,8 @@
 // Struct to steal stack
 struct current_stack_info_t {
-	__stack_t * storage;		// pointer to stack object
-	void *base;				// base of stack
-	void *limit;			// stack grows towards stack limit
-	void *context;			// address of cfa_context_t
+	__stack_t * storage;								// pointer to stack object
+	void * base;										// base of stack
+	void * limit;										// stack grows towards stack limit
+	void * context;										// address of cfa_context_t
 };
 
@@ -173,7 +173,7 @@
 	name = "Main Thread";
 	state = Start;
-	starter = NULL;
-	last = NULL;
-	cancellation = NULL;
+	starter = 0p;
+	last = 0p;
+	cancellation = 0p;
 }
 
@@ -186,8 +186,8 @@
 	self_mon.recursion = 1;
 	self_mon_p = &self_mon;
-	next = NULL;
-
-	node.next = NULL;
-	node.prev = NULL;
+	next = 0p;
+
+	node.next = 0p;
+	node.prev = 0p;
 	doregister(curr_cluster, this);
 
@@ -213,5 +213,5 @@
 	terminated{ 0 };
 	do_terminate = false;
-	preemption_alarm = NULL;
+	preemption_alarm = 0p;
 	pending_preemption = false;
 	runner.proc = &this;
@@ -233,5 +233,5 @@
 	}
 
-	pthread_join( kernel_thread, NULL );
+	pthread_join( kernel_thread, 0p );
 	free( this.stack );
 }
@@ -280,5 +280,5 @@
 		__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
 
-		thread_desc * readyThread = NULL;
+		thread_desc * readyThread = 0p;
 		for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
 		{
@@ -412,5 +412,5 @@
 	processor * proc = (processor *) arg;
 	kernelTLS.this_processor = proc;
-	kernelTLS.this_thread    = NULL;
+	kernelTLS.this_thread    = 0p;
 	kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
 	// SKULLDUGGERY: We want to create a context for the processor coroutine
@@ -425,5 +425,5 @@
 
 	//Set global state
-	kernelTLS.this_thread    = NULL;
+	kernelTLS.this_thread = 0p;
 
 	//We now have a proper context from which to schedule threads
@@ -441,5 +441,32 @@
 	__cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
 
-	return NULL;
+	return 0p;
+}
+
+static void Abort( int ret, const char * func ) {
+	if ( ret ) {
+		abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
+	} // if
+} // Abort
+
+void * create_pthread( pthread_t * pthread, void * (*start)(void *), void * arg ) {
+	pthread_attr_t attr;
+
+	Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
+
+#ifdef __CFA_DEBUG__
+	size_t guardsize;
+	Abort( pthread_attr_getguardsize( &attr, &guardsize ), "pthread_attr_getguardsize" );
+	Abort( pthread_attr_setguardsize( &attr, guardsize ), "pthread_attr_setguardsize" );
+#endif
+
+	size_t stacksize;
+	Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); // default stack size, normally defined by shell limit
+	assert( stacksize >= PTHREAD_STACK_MIN );
+	void * stack = malloc( stacksize );
+	Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 
+
+	Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
+	return stack;
 }
 
@@ -447,29 +474,5 @@
 	__cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
 
-	pthread_attr_t attr;
-	int ret;
-	ret = pthread_attr_init( &attr );					// initialize attribute
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_init failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-
-	size_t stacksize;
-	ret = pthread_attr_getstacksize( &attr, &stacksize ); // default stack size, normally defined by shell limit
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_getstacksize failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-	assert( stacksize >= PTHREAD_STACK_MIN );
-
-	this->stack = malloc( stacksize );
-	ret = pthread_attr_setstack( &attr, this->stack, stacksize ); 
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_setstack failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-
-	ret = pthread_create( &this->kernel_thread, &attr, CtxInvokeProcessor, (void *)this );
-	if ( ret ) {
-		abort( "%s : internal error, pthread_create failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-//	pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
+	this->stack = create_pthread( &this->kernel_thread, CtxInvokeProcessor, (void *)this );
 
 	__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
@@ -528,5 +531,5 @@
 	verify( ! kernelTLS.preemption_state.enabled );
 
-	verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
+	verifyf( thrd->next == 0p, "Expected null got %p", thrd->next );
 
 	with( *thrd->curr_cluster ) {
@@ -707,5 +710,5 @@
 	void ?{}(processorCtx_t & this, processor * proc) {
 		(this.__cor){ "Processor" };
-		this.__cor.starter = NULL;
+		this.__cor.starter = 0p;
 		this.proc = proc;
 	}
@@ -716,5 +719,5 @@
 		terminated{ 0 };
 		do_terminate = false;
-		preemption_alarm = NULL;
+		preemption_alarm = 0p;
 		pending_preemption = false;
 		kernel_thread = pthread_self();
@@ -910,5 +913,5 @@
 
 void V(semaphore & this) with( this ) {
-	thread_desc * thrd = NULL;
+	thread_desc * thrd = 0p;
 	lock( lock __cfaabi_dbg_ctx2 );
 	count += 1;
Index: libcfa/src/concurrency/kernel_private.hfa
===================================================================
--- libcfa/src/concurrency/kernel_private.hfa	(revision e8c52cf03237e8eb838f2de7d6a65626299a417b)
+++ libcfa/src/concurrency/kernel_private.hfa	(revision 39014579a68bf3e90d49ec9648e7f3f4a5c05b4f)
@@ -10,6 +10,6 @@
 // Created On       : Mon Feb 13 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Mar 29 14:06:40 2018
-// Update Count     : 3
+// Last Modified On : Sat Nov 30 19:25:02 2019
+// Update Count     : 8
 //
 
@@ -56,4 +56,6 @@
 // Processor
 void main(processorCtx_t *);
+
+void * create_pthread( pthread_t *, void * (*)(void *), void * );
 
 static inline void wake_fast(processor * this) {
Index: libcfa/src/concurrency/preemption.cfa
===================================================================
--- libcfa/src/concurrency/preemption.cfa	(revision e8c52cf03237e8eb838f2de7d6a65626299a417b)
+++ libcfa/src/concurrency/preemption.cfa	(revision 39014579a68bf3e90d49ec9648e7f3f4a5c05b4f)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 5 14:20:42 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Nov 30 08:02:56 2019
-// Update Count     : 39
+// Last Modified On : Sun Dec  1 22:22:56 2019
+// Update Count     : 41
 //
 
@@ -306,28 +306,5 @@
 	signal_block( SIGALRM );
 
-	pthread_attr_t attr;
-	int ret;
-	ret = pthread_attr_init( &attr );					// initialize attribute
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_init failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-
-	size_t stacksize;
-	ret = pthread_attr_getstacksize( &attr, &stacksize ); // default stack size, normally defined by shell limit
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_getstacksize failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-	assert( stacksize >= PTHREAD_STACK_MIN );
-
-	kernelTLS.preemption_state.stack = malloc( stacksize );
-	ret = pthread_attr_setstack( &attr, kernelTLS.preemption_state.stack, stacksize ); 
-	if ( ret ) {
-		abort( "%s : internal error, pthread_attr_setstack failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
-
-	ret = pthread_create( &alarm_thread, &attr, alarm_loop, 0p );
-	if ( ret ) {
-		abort( "%s : internal error, pthread_create failed, error(%d) %s.", __PRETTY_FUNCTION__, ret, strerror( ret ) );
-	} // if
+	kernelTLS.preemption_state.stack = create_pthread( &alarm_thread, alarm_loop, 0p );
 }
 
