Index: libcfa/src/concurrency/locks.cfa
===================================================================
--- libcfa/src/concurrency/locks.cfa	(revision 8cb06b671a14fffb7125da0255c714ea972727cf)
+++ libcfa/src/concurrency/locks.cfa	(revision 5a059463785617a734ec20e395e6f149d89171a0)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// locks.hfa -- LIBCFATHREAD
+// locks.cfa -- LIBCFATHREAD
 // Runtime locks that used with the runtime thread system.
 //
@@ -113,12 +113,4 @@
 	return ret;
 }
-
-// static void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
-// 	thread$ * t = &try_pop_front( blocked_threads );
-// 	owner = t;
-// 	recursion_count = ( t ? 1 : 0 );
-// 	if ( t ) wait_count--;
-// 	unpark( t );
-// }
 
 static inline void pop_node( blocking_lock & this ) with( this ) {
@@ -388,18 +380,12 @@
 		insert_last( blocked_threads, *i );
 		count++;
-		// size_t recursion_count = 0;
-		// if (i->lock) {
-		// 	// if lock was passed get recursion count to reset to after waking thread
-		// 	recursion_count = on_wait( *i->lock );
-		// }
-		// return recursion_count;
 	}
 
     static size_t block_and_get_recursion( info_thread(L) & i, __cfa_pre_park pp_fn, void * pp_datum ) {
         size_t recursion_count = 0;
-		if ( i.lock ) {
-			// if lock was passed get recursion count to reset to after waking thread
+		if ( i.lock ) // if lock was passed get recursion count to reset to after waking thread
 			recursion_count = on_wait( *i.lock, pp_fn, pp_datum ); // this call blocks
-		} else pre_park_then_park( pp_fn, pp_datum );
+		else
+            pre_park_then_park( pp_fn, pp_datum );
         return recursion_count;
     }
@@ -410,10 +396,8 @@
 		lock( lock __cfaabi_dbg_ctx2 );
         enqueue_thread( this, &i );
-		// size_t recursion_count = queue_and_get_recursion( this, &i );
 		unlock( lock );
 
 		// blocks here
         size_t recursion_count = block_and_get_recursion( i );
-		// park( );
 
 		// resets recursion count here after waking
@@ -431,12 +415,8 @@
 		lock( lock __cfaabi_dbg_ctx2 );
         enqueue_thread( this, &info );
-		// size_t recursion_count = queue_and_get_recursion( this, &info );
 		alarm_node_wrap(L) node_wrap = { t, 0`s, callback, &this, &info };
 		unlock( lock );
 
-		// registers alarm outside cond lock to avoid deadlock
-		// register_self( &node_wrap.alarm_node );
-
-		// blocks here
+		// blocks here and registers alarm node before blocking after releasing locks to avoid deadlock
         size_t recursion_count = block_and_get_recursion( info, cond_alarm_register, (void *)(&node_wrap.alarm_node) );
 		// park();
@@ -548,27 +528,14 @@
 	bool empty ( pthread_cond_var(L) & this ) with(this) { return blocked_threads`isEmpty; }
 
-	// static size_t queue_and_get_recursion( pthread_cond_var(L) & this, info_thread(L) * i ) with(this) {
-	// 	// add info_thread to waiting queue
-	// 	insert_last( blocked_threads, *i );
-	// 	size_t recursion_count = 0;
-	// 	recursion_count = on_wait( *i->lock );
-	// 	return recursion_count;
-	// }
-	
 	static void queue_info_thread_timeout( pthread_cond_var(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
 		lock( lock __cfaabi_dbg_ctx2 );
-		// size_t recursion_count = queue_and_get_recursion(this, &info);
         insert_last( blocked_threads, info );
 		pthread_alarm_node_wrap(L) node_wrap = { t, 0`s, callback, &this, &info };
 		unlock( lock );
 
-		// registers alarm outside cond lock to avoid deadlock
-		// register_self( &node_wrap.alarm_node ); // C_TODO: fix race: registers itself and then alarm handler calls on_notify before block_and_get_recursion is run
-
-		// blocks here
+		// blocks here and registers alarm node before blocking after releasing locks to avoid deadlock
         size_t recursion_count = block_and_get_recursion( info, cond_alarm_register, (void *)(&node_wrap.alarm_node) );
-		// park();
-
-		// unregisters alarm so it doesn't go off if this happens first
+
+		// unregisters alarm so it doesn't go off if signal happens first
 		unregister_self( &node_wrap.alarm_node );
 
@@ -585,10 +552,9 @@
 		info_thread( L ) i = { active_thread(), info, &l };
         insert_last( blocked_threads, i );
-		// size_t recursion_count = queue_and_get_recursion( this, &i );
 		unlock( lock );
 
         // blocks here
 		size_t recursion_count = block_and_get_recursion( i );
-		// park();
+
 		on_wakeup( *i.lock, recursion_count );
 	}
@@ -679,2 +645,3 @@
 	return thrd != 0p;
 }
+
Index: libcfa/src/concurrency/locks.hfa
===================================================================
--- libcfa/src/concurrency/locks.hfa	(revision 8cb06b671a14fffb7125da0255c714ea972727cf)
+++ libcfa/src/concurrency/locks.hfa	(revision 5a059463785617a734ec20e395e6f149d89171a0)
@@ -39,9 +39,4 @@
 #include <unistd.h>
 
-// C_TODO: cleanup this and locks.cfa
-// - appropriate separation of interface and impl
-// - clean up unused/unneeded locks
-// - change messy big blocking lock from inheritance to composition to remove need for flags
-
 typedef void (*__cfa_pre_park)( void * );
 
@@ -66,4 +61,26 @@
     park();
 }
+
+// macros for default routine impls for is_blocking_lock trait that do not wait-morph
+
+#define DEFAULT_ON_NOTIFY( lock_type ) \
+    static inline void on_notify( lock_type & this, thread$ * t ){ unpark(t); }
+
+#define DEFAULT_ON_WAIT( lock_type ) \
+    static inline size_t on_wait( lock_type & this, __cfa_pre_park pp_fn, void * pp_datum ) { \
+        unlock( this ); \
+        pre_park_then_park( pp_fn, pp_datum ); \
+        return 0; \
+    }
+
+// on_wakeup impl if lock should be reacquired after waking up
+#define DEFAULT_ON_WAKEUP_REACQ( lock_type ) \
+    static inline void on_wakeup( lock_type & this, size_t recursion ) { lock( this ); }
+
+// on_wakeup impl if lock will not be reacquired after waking up
+#define DEFAULT_ON_WAKEUP_NO_REACQ( lock_type ) \
+    static inline void on_wakeup( lock_type & this, size_t recursion ) {}
+
+
 
 //-----------------------------------------------------------------------------
@@ -187,4 +204,5 @@
 // - Kernel thd blocking alternative to the spinlock
 // - No ownership (will deadlock on reacq)
+// - no reacq on wakeup
 struct futex_mutex {
 	// lock state any state other than UNLOCKED is locked
@@ -200,11 +218,11 @@
 }
 
-static inline void  ?{}( futex_mutex & this ) with(this) { val = 0; }
-
-static inline bool internal_try_lock(futex_mutex & this, int & compare_val) with(this) {
+static inline void ?{}( futex_mutex & this ) with(this) { val = 0; }
+
+static inline bool internal_try_lock( futex_mutex & this, int & compare_val) with(this) {
 	return __atomic_compare_exchange_n((int*)&val, (int*)&compare_val, 1, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
 }
 
-static inline int internal_exchange(futex_mutex & this) with(this) {
+static inline int internal_exchange( futex_mutex & this ) with(this) {
 	return __atomic_exchange_n((int*)&val, 2, __ATOMIC_ACQUIRE);
 }
@@ -240,13 +258,7 @@
 }
 
-static inline void on_notify( futex_mutex & f, thread$ * t){ unpark(t); }
-static inline size_t on_wait( futex_mutex & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-
-// to set recursion count after getting signalled;
-static inline void on_wakeup( futex_mutex & f, size_t recursion ) {}
+DEFAULT_ON_NOTIFY( futex_mutex )
+DEFAULT_ON_WAIT( futex_mutex )
+DEFAULT_ON_WAKEUP_NO_REACQ( futex_mutex )
 
 //-----------------------------------------------------------------------------
@@ -264,6 +276,7 @@
 	int val; 
 };
-
 static inline void  ?{}( go_mutex & this ) with(this) { val = 0; }
+// static inline void ?{}( go_mutex & this, go_mutex this2 ) = void; // these don't compile correctly at the moment so they should be omitted
+// static inline void ?=?( go_mutex & this, go_mutex this2 ) = void;
 
 static inline bool internal_try_lock(go_mutex & this, int & compare_val, int new_val ) with(this) {
@@ -314,11 +327,7 @@
 }
 
-static inline void on_notify( go_mutex & f, thread$ * t){ unpark( t ); }
-static inline size_t on_wait( go_mutex & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-static inline void on_wakeup( go_mutex & f, size_t recursion ) {}
+DEFAULT_ON_NOTIFY( go_mutex )
+DEFAULT_ON_WAIT( go_mutex )
+DEFAULT_ON_WAKEUP_NO_REACQ( go_mutex )
 
 //-----------------------------------------------------------------------------
@@ -340,4 +349,6 @@
 	this.lock_value = 0;
 }
+static inline void ?{}( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;
+static inline void ?=?( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;
 
 static inline void  ^?{}( exp_backoff_then_block_lock & this ){}
@@ -392,11 +403,7 @@
 }
 
-static inline void on_notify( exp_backoff_then_block_lock & this, struct thread$ * t ) { unpark( t ); }
-static inline size_t on_wait( exp_backoff_then_block_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-static inline void on_wakeup( exp_backoff_then_block_lock & this, size_t recursion ) { lock( this ); }
+DEFAULT_ON_NOTIFY( exp_backoff_then_block_lock )
+DEFAULT_ON_WAIT( exp_backoff_then_block_lock )
+DEFAULT_ON_WAKEUP_REACQ( exp_backoff_then_block_lock )
 
 //-----------------------------------------------------------------------------
@@ -454,10 +461,6 @@
     unlock( lock );
 }
-static inline size_t on_wait( fast_block_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-static inline void on_wakeup( fast_block_lock & this, size_t recursion ) { }
+DEFAULT_ON_WAIT( fast_block_lock )
+DEFAULT_ON_WAKEUP_NO_REACQ( fast_block_lock )
 
 //-----------------------------------------------------------------------------
@@ -661,14 +664,7 @@
 }
 
-static inline void on_notify( spin_queue_lock & this, struct thread$ * t ) {
-	unpark(t);
-}
-static inline size_t on_wait( spin_queue_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-static inline void on_wakeup( spin_queue_lock & this, size_t recursion ) { lock( this ); }
-
+DEFAULT_ON_NOTIFY( spin_queue_lock )
+DEFAULT_ON_WAIT( spin_queue_lock )
+DEFAULT_ON_WAKEUP_REACQ( spin_queue_lock )
 
 //-----------------------------------------------------------------------------
@@ -708,11 +704,7 @@
 }
 
-static inline void on_notify( mcs_block_spin_lock & this, struct thread$ * t ) { unpark( t ); }
-static inline size_t on_wait( mcs_block_spin_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
-static inline void on_wakeup( mcs_block_spin_lock & this, size_t recursion ) {lock( this ); }
+DEFAULT_ON_NOTIFY( mcs_block_spin_lock )
+DEFAULT_ON_WAIT( mcs_block_spin_lock )
+DEFAULT_ON_WAKEUP_REACQ( mcs_block_spin_lock )
 
 //-----------------------------------------------------------------------------
@@ -765,9 +757,5 @@
 	unpark(t);
 }
-static inline size_t on_wait( block_spin_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) { 
-    unlock( this );
-    pre_park_then_park( pp_fn, pp_datum );
-    return 0;
-}
+DEFAULT_ON_WAIT( block_spin_lock )
 static inline void on_wakeup( block_spin_lock & this, size_t recursion ) with(this) {
 	// now we acquire the entire block_spin_lock upon waking up
Index: libcfa/src/concurrency/preemption.cfa
===================================================================
--- libcfa/src/concurrency/preemption.cfa	(revision 8cb06b671a14fffb7125da0255c714ea972727cf)
+++ libcfa/src/concurrency/preemption.cfa	(revision 5a059463785617a734ec20e395e6f149d89171a0)
@@ -117,5 +117,5 @@
 		__cfadbg_print_buffer_decl( preemption, " KERNEL: preemption tick %lu\n", currtime.tn);
 		Duration period = node->period;
-		if( period == 0) {
+		if( period == 0 ) {
 			node->set = false;                  // Node is one-shot, just mark it as not pending
 		}
