Index: libcfa/src/concurrency/locks.cfa
===================================================================
--- libcfa/src/concurrency/locks.cfa	(revision fece3d9aa36b07fac614e36fe2949b233e218114)
+++ libcfa/src/concurrency/locks.cfa	(revision 9f1beb43e8680e0e88365670c20430e1f307fb1b)
@@ -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;
 }
+
