Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/Common/PassVisitor.impl.h	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -1018,10 +1018,42 @@
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
-	VISIT_BODY( node );
+	VISIT_START( node );
+
+	for( auto & clause : node->clauses ) {
+		maybeAccept_impl( clause.target.function, *this );
+		maybeAccept_impl( clause.target.arguments, *this );
+
+		maybeAccept_impl( clause.statement, *this );
+		maybeAccept_impl( clause.condition, *this );
+	}
+
+	maybeAccept_impl( node->timeout.time, *this );
+	maybeAccept_impl( node->timeout.statement, *this );
+	maybeAccept_impl( node->timeout.condition, *this );
+	maybeAccept_impl( node->orelse.statement, *this );
+	maybeAccept_impl( node->orelse.condition, *this );
+
+	VISIT_END( node );
 }
 
 template< typename pass_type >
 Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
-	MUTATE_BODY( Statement, node );
+	MUTATE_START( node );
+
+	for( auto & clause : node->clauses ) {
+		maybeMutate_impl( clause.target.function, *this );
+		maybeMutate_impl( clause.target.arguments, *this );
+
+		maybeMutate_impl( clause.statement, *this );
+		maybeMutate_impl( clause.condition, *this );
+	}
+
+	maybeMutate_impl( node->timeout.time, *this );
+	maybeMutate_impl( node->timeout.statement, *this );
+	maybeMutate_impl( node->timeout.condition, *this );
+	maybeMutate_impl( node->orelse.statement, *this );
+	maybeMutate_impl( node->orelse.condition, *this );
+
+	MUTATE_END( Statement, node );
 }
 
Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/GenPoly/Lvalue.cc	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -465,4 +465,13 @@
 					return ret;
 				}
+			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * > ( arg ) ) {
+				// need to move cast to pointer type out a level since address of pointer
+				// is not valid C code (can be introduced in prior passes, e.g., InstantiateGeneric)
+				if ( InitTweak::getPointerBase( castExpr->result ) ) {
+					addrExpr->arg = castExpr->arg;
+					castExpr->arg = addrExpr;
+					castExpr->result = new PointerType( Type::Qualifiers(), castExpr->result );
+					return castExpr;
+				}
 			}
 			return addrExpr;
Index: src/libcfa/bits/debug.c
===================================================================
--- src/libcfa/bits/debug.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/bits/debug.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -11,5 +11,5 @@
 // Last Modified By :
 // Last Modified On :
-// Update Count     : 0
+// Update Count     : 1
 //
 
@@ -47,5 +47,5 @@
 	void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
 
-	void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {
+	void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
 		va_list args;
 
@@ -60,5 +60,5 @@
 	}
 
-	void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {
+	void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
 		va_list args;
 
@@ -76,5 +76,5 @@
 	}
 
-	void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )) {
+	void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
 		va_list args;
 
Index: src/libcfa/bits/debug.h
===================================================================
--- src/libcfa/bits/debug.h	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/bits/debug.h	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Mon Nov 28 12:27:26 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jul 22 10:02:24 2017
-// Update Count     : 1
+// Last Modified On : Thu Feb  8 12:35:19 2018
+// Update Count     : 2
 //
 
@@ -41,8 +41,8 @@
       extern void __cfaabi_dbg_bits_acquire();
       extern void __cfaabi_dbg_bits_release();
-      extern void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
-      extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
+      extern void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
+      extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
       extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg );
-      extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) ));
+      extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) ));
 #ifdef __cforall
 }
Index: src/libcfa/bits/defs.h
===================================================================
--- src/libcfa/bits/defs.h	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/bits/defs.h	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -1,16 +1,16 @@
-// 
+//
 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
 //
 // The contents of this file are covered under the licence agreement in the
 // file "LICENCE" distributed with Cforall.
-// 
-// defs.h -- 
-// 
+//
+// defs.h --
+//
 // Author           : Thierry Delisle
 // Created On       : Thu Nov  9 13:24:10 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jan  2 09:17:06 2018
-// Update Count     : 2
-// 
+// Last Modified On : Thu Feb  8 16:22:41 2018
+// Update Count     : 8
+//
 
 #pragma once
@@ -34,7 +34,8 @@
 
 #ifdef __cforall
+void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
 extern "C" {
 #endif
-void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__));
+void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
 #ifdef __cforall
 }
Index: src/libcfa/concurrency/coroutine.c
===================================================================
--- src/libcfa/concurrency/coroutine.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/coroutine.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Mon Nov 28 12:27:26 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul 21 22:34:57 2017
-// Update Count     : 1
+// Last Modified On : Thu Feb  8 16:10:31 2018
+// Update Count     : 4
 //
 
@@ -77,5 +77,5 @@
 		__cfaabi_dbg_debug_do(
 			if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {
-				abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
+				abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
 			}
 		);
@@ -135,10 +135,10 @@
 		__cfaabi_dbg_debug_do(
 			if ( mprotect( storage, pageSize, PROT_NONE ) == -1 ) {
-				abortf( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) );
+				abort( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) );
 			} // if
 		);
 
 		if ( (intptr_t)storage == 0 ) {
-			abortf( "Attempt to allocate %d bytes of storage for coroutine or task execution-state but insufficient memory available.", size );
+			abort( "Attempt to allocate %zd bytes of storage for coroutine or task execution-state but insufficient memory available.", size );
 		} // if
 
Index: src/libcfa/concurrency/invoke.c
===================================================================
--- src/libcfa/concurrency/invoke.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/invoke.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Feb  9 14:41:56 2018
-// Update Count     : 3
+// Last Modified On : Fri Feb  9 16:37:42 2018
+// Update Count     : 5
 //
 
@@ -51,5 +51,5 @@
 	//Final suspend, should never return
 	__leave_coroutine();
-	abortf("Resumed dead coroutine");
+	__cabi_abort( "Resumed dead coroutine" );
 }
 
@@ -81,5 +81,5 @@
 	//Final suspend, should never return
 	__leave_thread_monitor( thrd );
-	abortf("Resumed dead thread");
+	__cabi_abort( "Resumed dead thread" );
 }
 
Index: src/libcfa/concurrency/kernel.c
===================================================================
--- src/libcfa/concurrency/kernel.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/kernel.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -168,5 +168,5 @@
 	if( ! do_terminate ) {
 		__cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
-		do_terminate = true;
+		terminate(&this);
 		P( terminated );
 		pthread_join( kernel_thread, NULL );
Index: src/libcfa/concurrency/kernel_private.h
===================================================================
--- src/libcfa/concurrency/kernel_private.h	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/kernel_private.h	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -60,4 +60,5 @@
 void runThread(processor * this, thread_desc * dst);
 void finishRunning(processor * this);
+void terminate(processor * this);
 void spin(processor * this, unsigned int * spin_count);
 
Index: src/libcfa/concurrency/monitor.c
===================================================================
--- src/libcfa/concurrency/monitor.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/monitor.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Thd Feb 23 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jul 31 14:59:05 2017
-// Update Count     : 3
+// Last Modified On : Thu Feb  8 16:12:20 2018
+// Update Count     : 4
 //
 
@@ -87,5 +87,5 @@
 		thread_desc * thrd = this_thread;
 
-		__cfaabi_dbg_print_safe("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
 
 		if( !this->owner ) {
@@ -93,5 +93,5 @@
 			set_owner( this, thrd );
 
-			__cfaabi_dbg_print_safe("Kernel :  mon is free \n");
+			__cfaabi_dbg_print_safe( "Kernel :  mon is free \n" );
 		}
 		else if( this->owner == thrd) {
@@ -99,5 +99,5 @@
 			this->recursion += 1;
 
-			__cfaabi_dbg_print_safe("Kernel :  mon already owned \n");
+			__cfaabi_dbg_print_safe( "Kernel :  mon already owned \n" );
 		}
 		else if( is_accepted( this, group) ) {
@@ -108,8 +108,8 @@
 			reset_mask( this );
 
-			__cfaabi_dbg_print_safe("Kernel :  mon accepts \n");
+			__cfaabi_dbg_print_safe( "Kernel :  mon accepts \n" );
 		}
 		else {
-			__cfaabi_dbg_print_safe("Kernel :  blocking \n");
+			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
 
 			// Some one else has the monitor, wait in line for it
@@ -118,5 +118,5 @@
 			BlockInternal( &this->lock );
 
-			__cfaabi_dbg_print_safe("Kernel : %10p Entered  mon %p\n", thrd, this);
+			__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
 
 			// BlockInternal will unlock spinlock, no need to unlock ourselves
@@ -124,5 +124,5 @@
 		}
 
-		__cfaabi_dbg_print_safe("Kernel : %10p Entered  mon %p\n", thrd, this);
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
 
 		// Release the lock and leave
@@ -136,9 +136,9 @@
 		thread_desc * thrd = this_thread;
 
-		__cfaabi_dbg_print_safe("Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
 
 
 		if( !this->owner ) {
-			__cfaabi_dbg_print_safe("Kernel : Destroying free mon %p\n", this);
+			__cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this);
 
 			// No one has the monitor, just take it
@@ -151,5 +151,5 @@
 			// We already have the monitor... but where about to destroy it so the nesting will fail
 			// Abort!
-			abortf("Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.");
+			abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex." );
 		}
 
@@ -158,5 +158,5 @@
 		__monitor_group_t group = { &this, 1, func };
 		if( is_accepted( this, group) ) {
-			__cfaabi_dbg_print_safe("Kernel :  mon accepts dtor, block and signal it \n");
+			__cfaabi_dbg_print_safe( "Kernel :  mon accepts dtor, block and signal it \n" );
 
 			// Wake the thread that is waiting for this
@@ -177,5 +177,5 @@
 		}
 		else {
-			__cfaabi_dbg_print_safe("Kernel :  blocking \n");
+			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
 
 			wait_ctx( this_thread, 0 )
@@ -190,5 +190,5 @@
 		}
 
-		__cfaabi_dbg_print_safe("Kernel : Destroying %p\n", this);
+		__cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this);
 
 	}
@@ -199,5 +199,5 @@
 		lock( this->lock __cfaabi_dbg_ctx2 );
 
-		__cfaabi_dbg_print_safe("Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
+		__cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
 
 		verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
@@ -209,5 +209,5 @@
 		// it means we don't need to do anything
 		if( this->recursion != 0) {
-			__cfaabi_dbg_print_safe("Kernel :  recursion still %d\n", this->recursion);
+			__cfaabi_dbg_print_safe( "Kernel :  recursion still %d\n", this->recursion);
 			unlock( this->lock );
 			return;
@@ -228,8 +228,8 @@
 		__cfaabi_dbg_debug_do(
 			if( this_thread != this->owner ) {
-				abortf("Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);
+				abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);
 			}
 			if( this->recursion != 1 ) {
-				abortf("Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);
+				abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);
 			}
 		)
@@ -256,5 +256,5 @@
 		// If we haven't left the last level of recursion
 		// it must mean there is an error
-		if( this->recursion != 0) { abortf("Thread internal monitor has unbalanced recursion"); }
+		if( this->recursion != 0) { abort( "Thread internal monitor has unbalanced recursion" ); }
 
 		// Fetch the next thread, can be null
@@ -302,5 +302,5 @@
 	(this_thread->monitors){m, count, func};
 
-	// __cfaabi_dbg_print_safe("MGUARD : enter %d\n", count);
+	// __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
 
 	// Enter the monitors in order
@@ -308,5 +308,5 @@
 	enter( group );
 
-	// __cfaabi_dbg_print_safe("MGUARD : entered\n");
+	// __cfaabi_dbg_print_safe( "MGUARD : entered\n" );
 }
 
@@ -314,10 +314,10 @@
 // Dtor for monitor guard
 void ^?{}( monitor_guard_t & this ) {
-	// __cfaabi_dbg_print_safe("MGUARD : leaving %d\n", this.count);
+	// __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count);
 
 	// Leave the monitors in order
 	leave( this.m, this.count );
 
-	// __cfaabi_dbg_print_safe("MGUARD : left\n");
+	// __cfaabi_dbg_print_safe( "MGUARD : left\n" );
 
 	// Restore thread context
@@ -427,10 +427,10 @@
 		thread_desc * this_thrd = this_thread;
 		if ( this.monitor_count != this_thrd->monitors.size ) {
-			abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", &this, this.monitor_count, this_thrd->monitors.size );
+			abort( "Signal on condition %p made with different number of monitor(s), expected %i got %i", &this, this.monitor_count, this_thrd->monitors.size );
 		}
 
 		for(int i = 0; i < this.monitor_count; i++) {
 			if ( this.monitors[i] != this_thrd->monitors[i] ) {
-				abortf( "Signal on condition %p made with different monitor, expected %p got %i", &this, this.monitors[i], this_thrd->monitors[i] );
+				abort( "Signal on condition %p made with different monitor, expected %p got %i", &this, this.monitors[i], this_thrd->monitors[i] );
 			}
 		}
@@ -534,5 +534,5 @@
 	if(actual_count == 0) return;
 
-	__cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n");
+	__cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n" );
 
 	// Create storage for monitor context
@@ -551,5 +551,5 @@
 			__acceptable_t& accepted = mask[index];
 			if( accepted.is_dtor ) {
-				__cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n");
+				__cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n" );
 				verifyf( accepted.size == 1,  "ERROR: Accepted dtor has more than 1 mutex parameter." );
 
@@ -563,5 +563,5 @@
 			}
 			else {
-				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n");
+				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n" );
 
 				// Create the node specific to this wait operation
@@ -577,5 +577,5 @@
 					}
 				#endif
-				__cfaabi_dbg_print_buffer_local( "\n");
+				__cfaabi_dbg_print_buffer_local( "\n" );
 
 				// Set the owners to be the next thread
@@ -588,5 +588,5 @@
 				monitor_restore;
 
-				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n");
+				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n" );
 			}
 
@@ -598,5 +598,5 @@
 
 	if( duration == 0 ) {
-		__cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n");
+		__cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n" );
 
 		unlock_all( locks, count );
@@ -607,7 +607,7 @@
 
 
-	verifyf( duration < 0, "Timeout on waitfor statments not supported yet.");
-
-	__cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n");
+	verifyf( duration < 0, "Timeout on waitfor statments not supported yet." );
+
+	__cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n" );
 
 	// Create the node specific to this wait operation
@@ -631,5 +631,5 @@
 	monitor_restore;
 
-	__cfaabi_dbg_print_buffer_local( "Kernel : exiting\n");
+	__cfaabi_dbg_print_buffer_local( "Kernel : exiting\n" );
 
 	__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
@@ -640,5 +640,5 @@
 
 static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
-	// __cfaabi_dbg_print_safe("Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
+	// __cfaabi_dbg_print_safe( "Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
 
 	//Pass the monitor appropriately
@@ -672,5 +672,5 @@
 static inline thread_desc * next_thread( monitor_desc * this ) {
 	//Check the signaller stack
-	__cfaabi_dbg_print_safe("Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
+	__cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
 	__condition_criterion_t * urgent = pop( this->signal_stack );
 	if( urgent ) {
@@ -814,5 +814,5 @@
 	thread_desc * thrd = this_thread;
 	if( !this.monitors ) {
-		// __cfaabi_dbg_print_safe("Branding\n");
+		// __cfaabi_dbg_print_safe( "Branding\n" );
 		assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
 		this.monitor_count = thrd->monitors.size;
Index: src/libcfa/concurrency/preemption.c
===================================================================
--- src/libcfa/concurrency/preemption.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/concurrency/preemption.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 5 14:20:42 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Feb  9 14:42:34 2018
-// Update Count     : 25
+// Last Modified On : Fri Feb  9 16:38:13 2018
+// Update Count     : 14
 //
 
@@ -67,4 +67,9 @@
 }
 
+enum {
+	PREEMPT_NORMAL    = 0,
+	PREEMPT_TERMINATE = 1,
+};
+
 //=============================================================================================
 // Kernel Preemption logic
@@ -192,5 +197,5 @@
 
 	if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
-	    abortf( "internal error, pthread_sigmask" );
+	    abort( "internal error, pthread_sigmask" );
 	}
 }
@@ -203,5 +208,5 @@
 
 	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
-	    abortf( "internal error, pthread_sigmask" );
+	    abort( "internal error, pthread_sigmask" );
 	}
 }
@@ -209,5 +214,13 @@
 // kill wrapper : signal a processor
 static void preempt( processor * this ) {
-	pthread_kill( this->kernel_thread, SIGUSR1 );
+	sigval_t value = { PREEMPT_NORMAL };
+	pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
+}
+
+// kill wrapper : signal a processor
+void terminate(processor * this) {
+	this->do_terminate = true;
+	sigval_t value = { PREEMPT_TERMINATE };
+	pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
 }
 
@@ -234,5 +247,5 @@
 // Called from kernel_startup
 void kernel_start_preemption() {
-	__cfaabi_dbg_print_safe("Kernel : Starting preemption\n");
+	__cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" );
 
 	// Start with preemption disabled until ready
@@ -255,5 +268,5 @@
 // Called from kernel_shutdown
 void kernel_stop_preemption() {
-	__cfaabi_dbg_print_safe("Kernel : Preemption stopping\n");
+	__cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" );
 
 	// Block all signals since we are already shutting down
@@ -271,5 +284,5 @@
 	// Preemption is now fully stopped
 
-	__cfaabi_dbg_print_safe("Kernel : Preemption stopped\n");
+	__cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n" );
 }
 
@@ -299,8 +312,21 @@
 	__cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); )
 
+	// SKULLDUGGERY: if a thread creates a processor and the immediately deletes it,
+	// the interrupt that is supposed to force the kernel thread to preempt might arrive
+	// before the kernel thread has even started running. When that happens an iterrupt
+	// we a null 'this_processor' will be caught, just ignore it.
+	if(!this_processor) return;
+
+	choose(sfp->si_value.sival_int) {
+		case PREEMPT_NORMAL   : ;// Normal case, nothing to do here
+		case PREEMPT_TERMINATE: verify(this_processor->do_terminate);
+		default:
+			abort( "internal error, signal value is %d", sfp->si_value.sival_int );
+	}
+
 	// Check if it is safe to preempt here
 	if( !preemption_ready() ) { return; }
 
-	__cfaabi_dbg_print_buffer_decl(" KERNEL: preempting core %p (%p).\n", this_processor, this_thread);
+	__cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread);
 
 	preemption_in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
@@ -322,5 +348,5 @@
 
 	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
-	    abortf( "internal error, pthread_sigmask" );
+	    abort( "internal error, pthread_sigmask" );
 	}
 
@@ -339,7 +365,7 @@
 					continue;
        			case EINVAL :
-				 	abortf("Timeout was invalid.");
+				 	abort( "Timeout was invalid." );
 				default:
-				 	abortf("Unhandled error %d", err);
+				 	abort( "Unhandled error %d", err);
 			}
 		}
@@ -348,5 +374,5 @@
 		assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int);
 
-		// __cfaabi_dbg_print_safe("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );
+		// __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );
 		// Switch on the code (a.k.a. the sender) to
 		switch( info.si_code )
@@ -356,5 +382,5 @@
 		case SI_TIMER:
 		case SI_KERNEL:
-			// __cfaabi_dbg_print_safe("Kernel : Preemption thread tick\n");
+			// __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" );
 			lock( event_kernel->lock __cfaabi_dbg_ctx2 );
 			tick_preemption();
@@ -370,5 +396,5 @@
 
 EXIT:
-	__cfaabi_dbg_print_safe("Kernel : Preemption thread stopping\n");
+	__cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
 	return NULL;
 }
Index: src/libcfa/interpose.c
===================================================================
--- src/libcfa/interpose.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/libcfa/interpose.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Mar 29 16:10:31 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Feb  6 17:57:56 2018
-// Update Count     : 49
+// Last Modified On : Thu Feb  8 16:18:09 2018
+// Update Count     : 75
 //
 
@@ -33,4 +33,8 @@
 #include "startup.h"
 
+//=============================================================================================
+// Interposing helpers
+//=============================================================================================
+
 typedef void (*generic_fptr_t)(void);
 generic_fptr_t interpose_symbol( const char* symbol, const char *version ) {
@@ -46,5 +50,5 @@
 			error = dlerror();
 			if ( error ) {
-				abortf( "interpose_symbol : failed to open libc, %s\n", error );
+				abort( "interpose_symbol : failed to open libc, %s\n", error );
 			}
 		#endif
@@ -64,15 +68,11 @@
 
 	error = dlerror();
-	if ( error ) abortf( "interpose_symbol : internal error, %s\n", error );
+	if ( error ) abort( "interpose_symbol : internal error, %s\n", error );
 
 	return originalFunc.fptr;
 }
 
-
-__typeof__( exit ) libc_exit __attribute__(( noreturn ));
-__typeof__( abort ) libc_abort __attribute__(( noreturn ));
-
 forall(dtype T)
-static inline void assign_ptr( T** symbol_ptr, const char * symbol_name, const char * version) {
+static inline void ptr_from_symbol( T** symbol_ptr, const char * symbol_name, const char * version) {
 	union {
 		generic_fptr_t gp;
@@ -85,5 +85,9 @@
 }
 
-#define INIT_REALRTN( x, ver ) assign_ptr( (void**)&libc_##x, #x, ver)
+#define INTERPOSE_LIBC( x, ver ) ptr_from_symbol( (void**)&__cabi_libc.x, #x, ver)
+
+//=============================================================================================
+// Terminating Signals logic
+//=============================================================================================
 
 void sigHandler_segv ( __CFA_SIGPARMS__ );
@@ -92,4 +96,9 @@
 void sigHandler_abort( __CFA_SIGPARMS__ );
 
+struct {
+	void (* exit)( int ) __attribute__ (( __noreturn__ ));
+	void (* abort)( void ) __attribute__ (( __noreturn__ ));
+} __cabi_libc;
+
 extern "C" {
 	void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
@@ -97,6 +106,6 @@
 		const char *version = NULL;
 
-		INIT_REALRTN( abort, version );
-		INIT_REALRTN( exit, version );
+		INTERPOSE_LIBC( abort, version );
+		INTERPOSE_LIBC( exit , version );
 
 		__cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler
@@ -112,24 +121,28 @@
 //=============================================================================================
 
+// Forward declare abort after the __typeof__ call to avoid ambiguities
+void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
+void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
+
 extern "C" {
-	void abort( void ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
-		abortf( NULL );
-	}
-
-	void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
-		libc_exit(__status);
-	}
-}
-
-void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
-	va_list argp;
-	va_start( argp, fmt );
-	abortf( fmt, argp );
-	va_end( argp );
-}
-
-void * kernel_abort    ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
-void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ ((__nothrow__, __leaf__, __weak__)) {}
-int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return 4; }
+	void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) {
+		abort( NULL );
+	}
+
+	void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
+		va_list argp;
+		va_start( argp, fmt );
+		abort( fmt, argp );
+		va_end( argp );
+	}
+
+	void exit( int status ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) {
+		__cabi_libc.exit( status );
+	}
+}
+
+void * kernel_abort    ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return NULL; }
+void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) {}
+int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return 4; }
 
 enum { abort_text_size = 1024 };
@@ -137,29 +150,35 @@
 static int abort_lastframe;
 
-extern "C" {
-	void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
-		void * kernel_data = kernel_abort();			// must be done here to lock down kernel
-		int len;
-
-		abort_lastframe = kernel_abort_lastframe();
-		len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
+void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
+    va_list args;
+    va_start( args, fmt );
+    vfprintf( stderr, fmt, args );
+    va_end( args );
+	__cabi_libc.exit( status );
+}
+
+void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
+	void * kernel_data = kernel_abort();			// must be done here to lock down kernel
+	int len;
+
+	abort_lastframe = kernel_abort_lastframe();
+	len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
+	__cfaabi_dbg_bits_write( abort_text, len );
+
+	if ( fmt ) {
+		va_list args;
+		va_start( args, fmt );
+
+		len = vsnprintf( abort_text, abort_text_size, fmt, args );
+		va_end( args );
 		__cfaabi_dbg_bits_write( abort_text, len );
 
-		if ( fmt ) {
-			va_list args;
-			va_start( args, fmt );
-
-			len = vsnprintf( abort_text, abort_text_size, fmt, args );
-			va_end( args );
-			__cfaabi_dbg_bits_write( abort_text, len );
-
-			if ( fmt[strlen( fmt ) - 1] != '\n' ) {		// add optional newline if missing at the end of the format text
-				__cfaabi_dbg_bits_write( "\n", 1 );
-			}
-		}
-
-		kernel_abort_msg( kernel_data, abort_text, abort_text_size );
-		libc_abort();
-	}
+		if ( fmt[strlen( fmt ) - 1] != '\n' ) {		// add optional newline if missing at the end of the format text
+			__cfaabi_dbg_bits_write( "\n", 1 );
+		}
+	}
+
+	kernel_abort_msg( kernel_data, abort_text, abort_text_size );
+	__cabi_libc.abort();
 }
 
@@ -215,5 +234,5 @@
 
 void sigHandler_segv( __CFA_SIGPARMS__ ) {
-	abortf( "Attempt to address location %p\n"
+	abort( "Addressing invalid memory at location %p\n"
 			"Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
 			sfp->si_addr );
@@ -221,5 +240,5 @@
 
 void sigHandler_ill( __CFA_SIGPARMS__ ) {
-	abortf( "Attempt to execute code at location %p.\n"
+	abort( "Executing illegal instruction at location %p.\n"
 			"Possible cause is stack corruption.\n",
 			sfp->si_addr );
@@ -229,15 +248,13 @@
 	const char * msg;
 
-	switch ( sfp->si_code ) {
-	  case FPE_INTDIV:
-	  case FPE_FLTDIV: msg = "divide by zero"; break;
-	  case FPE_FLTOVF: msg = "overflow"; break;
-	  case FPE_FLTUND: msg = "underflow"; break;
-	  case FPE_FLTRES: msg = "inexact result"; break;
-	  case FPE_FLTINV: msg = "invalid operation"; break;
+	choose( sfp->si_code ) {
+	  case FPE_INTDIV, FPE_FLTDIV: msg = "divide by zero";
+	  case FPE_FLTOVF: msg = "overflow";
+	  case FPE_FLTUND: msg = "underflow";
+	  case FPE_FLTRES: msg = "inexact result";
+	  case FPE_FLTINV: msg = "invalid operation";
 	  default: msg = "unknown";
-	} // switch
-	abortf( "Floating point error.\n"
-			"Cause is %s.\n", msg );
+	} // choose
+	abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
 }
 
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/main.cc	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -80,4 +80,5 @@
 	exprp = false,
 	expraltp = false,
+	genericsp = false,
 	libcfap = false,
 	nopreludep = false,
@@ -320,7 +321,12 @@
 		OPTPRINT("instantiateGenerics")
 		GenPoly::instantiateGeneric( translationUnit );
+		if ( genericsp ) {
+			dump( translationUnit );
+			return 0;
+		}
 		OPTPRINT( "convertLvalue" )
 		GenPoly::convertLvalue( translationUnit );
 
+
 		if ( bboxp ) {
 			dump( translationUnit );
@@ -340,7 +346,9 @@
 
 		CodeTools::fillLocations( translationUnit );
+		OPTPRINT( "codegen" )
 		CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks );
 
 		CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
+		OPTPRINT( "end" )
 
 		if ( output != &cout ) {
@@ -407,5 +415,5 @@
 
 	int c;
-	while ( (c = getopt_long( argc, argv, "abBcCdefglLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
+	while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
 		switch ( c ) {
 		  case Ast:
@@ -442,4 +450,7 @@
 		  case 'g':										// bison debugging info (grammar rules)
 			yydebug = true;
+			break;
+		  case 'G':                   // dump AST after instantiate generics
+			genericsp = true;
 			break;
 		  case LibCFA:
Index: src/prelude/builtins.c
===================================================================
--- src/prelude/builtins.c	(revision 381fdee5d28e58b7c6f73f40e6d72ec1f6dfc7d1)
+++ src/prelude/builtins.c	(revision 48786bc83eabdac1ae1f86fedac9eabccbf9bcb5)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Fri Jul 21 16:21:03 2017
-// Last Modified By : Andrew Beach
-// Last Modified On : Tus Jul 25 15:33:00 2017
-// Update Count     : 14
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Feb  8 12:47:59 2018
+// Update Count     : 19
 //
 
@@ -20,4 +20,7 @@
 #include "../libcfa/virtual.h"
 #include "../libcfa/exception.h"
+
+void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
+void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
 
 // exponentiation operator implementation
