Index: src/libcfa/concurrency/invoke.h
===================================================================
--- src/libcfa/concurrency/invoke.h	(revision b18830e160544a32e0d1b1ea1100232bf1c4545d)
+++ src/libcfa/concurrency/invoke.h	(revision 6ae8c9224918ef2c006d4c8bf50aea46e0c7a205)
@@ -84,4 +84,10 @@
       };
 
+      struct __waitfor_mask_t {
+            short * accepted;                         // the index of the accepted function, -1 if none
+            struct __acceptable_t * clauses;          // list of acceptable functions, null if any
+            short size;                               // number of acceptable functions
+      };
+
       struct monitor_desc {
             struct spinlock lock;                     // spinlock to protect internal data
@@ -90,11 +96,8 @@
             struct __condition_stack_t signal_stack;  // stack of conditions to run next once we exit the monitor
             unsigned int recursion;                   // monitor routines can be called recursively, we need to keep track of that
-
-            struct __acceptable_t * acceptables;      // list of acceptable functions, null if any
-            unsigned short acceptable_count;          // number of acceptable functions
-            short accepted_index;                     // the index of the accepted function, -1 if none
+            struct __waitfor_mask_t mask;               // mask used to know if some thread is waiting for something while holding the monitor
       };
 
-      struct __monitor_group {
+      struct __monitor_group_t {
             struct monitor_desc ** list;              // currently held monitors
             short                  size;              // number of currently held monitors
@@ -107,5 +110,5 @@
             struct monitor_desc    self_mon;          // monitor body used for mutual exclusion
             struct monitor_desc *  self_mon_p;        // pointer to monitor with sufficient lifetime for current monitors
-            struct __monitor_group monitors;          // monitors currently held by this thread
+            struct __monitor_group_t monitors;          // monitors currently held by this thread
 
             // Link lists fields
@@ -117,9 +120,9 @@
      #ifdef __CFORALL__
      extern "Cforall" {
-            static inline monitor_desc * ?[?]( const __monitor_group & this, ptrdiff_t index ) {
+            static inline monitor_desc * ?[?]( const __monitor_group_t & this, ptrdiff_t index ) {
                   return this.list[index];
             }
 
-            static inline bool ?==?( const __monitor_group & lhs, const __monitor_group & rhs ) {
+            static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {
                   if( lhs.size != rhs.size ) return false;
                   if( lhs.func != rhs.func ) return false;
Index: src/libcfa/concurrency/monitor
===================================================================
--- src/libcfa/concurrency/monitor	(revision b18830e160544a32e0d1b1ea1100232bf1c4545d)
+++ src/libcfa/concurrency/monitor	(revision 6ae8c9224918ef2c006d4c8bf50aea46e0c7a205)
@@ -33,7 +33,7 @@
 	(this.signal_stack){};
 	this.recursion = 0;
-	this.acceptables = NULL;
-	this.acceptable_count = 0;
-	this.accepted_index = -1;
+	this.mask.accepted = NULL;
+	this.mask.clauses  = NULL;
+	this.mask.size     = 0;
 }
 
@@ -105,9 +105,9 @@
 
 struct __acceptable_t {
-	__monitor_group monitors;
+	__monitor_group_t monitors;
 	bool is_dtor;
 };
 
-int __waitfor_internal( unsigned short count, __acceptable_t * acceptables, int duration );
+void __waitfor_internal( const __waitfor_mask_t & mask, int duration );
 
 // Local Variables: //
Index: src/libcfa/concurrency/monitor.c
===================================================================
--- src/libcfa/concurrency/monitor.c	(revision b18830e160544a32e0d1b1ea1100232bf1c4545d)
+++ src/libcfa/concurrency/monitor.c	(revision 6ae8c9224918ef2c006d4c8bf50aea46e0c7a205)
@@ -25,5 +25,5 @@
 static inline void set_owner( monitor_desc * this, thread_desc * owner );
 static inline thread_desc * next_thread( monitor_desc * this );
-static inline int is_accepted( thread_desc * owner, monitor_desc * this, const __monitor_group & monitors );
+static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
 
 static inline void lock_all( spinlock ** locks, unsigned short count );
@@ -42,9 +42,9 @@
 static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val );
 
-static inline [thread_desc *, int] search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count );
-
-static inline short count_max( short acc_count, __acceptable_t * acceptables );
-static inline short aggregate( monitor_desc ** storage, short count, __acceptable_t * acceptables );
-static inline void  set_mask ( monitor_desc ** storage, short count, __acceptable_t * acceptables, short acc_count );
+static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc ** monitors, int count );
+
+static inline short count_max( const __waitfor_mask_t & mask );
+static inline short aggregate( monitor_desc ** storage, const __waitfor_mask_t & mask );
+static inline void  set_mask ( monitor_desc ** storage, short count, const __waitfor_mask_t & mask );
 
 //-----------------------------------------------------------------------------
@@ -72,5 +72,5 @@
 extern "C" {
 	// Enter single monitor
-	static void __enter_monitor_desc( const __monitor_group & group ) {
+	static void __enter_monitor_desc( const __monitor_group_t & group ) {
 		monitor_desc * this = group.list[0];
 
@@ -81,5 +81,4 @@
 		LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
 
-		this->accepted_index = -1;
 		if( !this->owner ) {
 			// No one has the monitor, just take it
@@ -95,5 +94,5 @@
 			LIB_DEBUG_PRINT_SAFE("Kernel :  mon already owned \n");
 		}
-		else if( (this->accepted_index = is_accepted( thrd, this, group)) >= 0 ) {
+		else if( is_accepted( this, group) ) {
 			// Some one was waiting for us, enter
 			set_owner( this, thrd );
@@ -184,5 +183,5 @@
 // Enter multiple monitor
 // relies on the monitor array being sorted
-static inline void enter( __monitor_group monitors ) {
+static inline void enter( __monitor_group_t monitors ) {
 	for(int i = 0; i < monitors.size; i++) {
 		__enter_monitor_desc( monitors );
@@ -219,5 +218,5 @@
 
 	// Enter the monitors in order
-	__monitor_group group = {this.m, this.count, func};
+	__monitor_group_t group = {this.m, this.count, func};
 	enter( group );
 }
@@ -417,10 +416,10 @@
 // 		setup mask
 // 		block
-int __waitfor_internal( unsigned short acc_count, __acceptable_t * acceptables, int duration ) {
+void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
 	// This statment doesn't have a contiguous list of monitors...
 	// Create one!
-	short max = count_max( acc_count, acceptables );
+	short max = count_max( mask );
 	monitor_desc * mon_storage[max];
-	short actual_count = aggregate( mon_storage, acc_count, acceptables );
+	short actual_count = aggregate( mon_storage, mask );
 
 	// Create storage for monitor context
@@ -432,10 +431,9 @@
 	{
 		// Check if the entry queue
-		thread_desc * next;
-		int index;
-		[next, index] = search_entry_queue( acceptables, acc_count, monitors, count );
+		thread_desc * next; int index;
+		[next, index] = search_entry_queue( mask, monitors, count );
 
 		if( next ) {
-			if( acceptables[index].is_dtor ) {
+			if( mask.clauses[index].is_dtor ) {
 				#warning case not implemented
 			}
@@ -463,5 +461,4 @@
 	if( duration == 0 ) return -1;
 
-	set_mask( monitors, count, acceptables, acc_count );
 
 	verifyf( duration < 0, "Timeout on waitfor statments not supported yet.");
@@ -469,4 +466,5 @@
 
 	save_recursion( monitors, recursions, count );
+	set_mask( monitors, count, mask );
 
 
@@ -481,8 +479,7 @@
 	lock_all( locks, count );
 	restore_recursion( monitors, recursions, count );
-	int acc_idx = monitors[0]->accepted_index;
 	unlock_all( locks, count );
 
-	return acc_idx;
+	return mask.accepted;
 }
 
@@ -625,26 +622,27 @@
 }
 
-static inline int is_accepted( thread_desc * owner, monitor_desc * this, const __monitor_group & group ) {
-	__acceptable_t* accs = this->acceptables; // Optim
-	int acc_cnt = this->acceptable_count;
+static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
+	__acceptable_t * it = this->mask.clauses; // Optim
+	int count = this->mask.size;
 
 	// Check if there are any acceptable functions
-	if( !accs ) return -1;
+	if( !it ) return -1;
 
 	// If this isn't the first monitor to test this, there is no reason to repeat the test.
-	if( this != group[0] ) return group[0]->accepted_index;
+	if( this != group[0] ) return group[0]->mask.accepted >= 0;
 
 	// For all acceptable functions check if this is the current function.
-	for( int i = 0; i < acc_cnt; i++ ) {
-		__acceptable_t * acc = &accs[i];
-
-		if( acc->monitors == group ) return i;
+	for( short i = 0; i < count; i++, it++ ) {
+		if( it->monitors == group ) {
+			*this->mask.accepted = i;
+			return true;
+		}
 	}
 
 	// No function matched
-	return -1;
-}
-
-static inline [thread_desc *, int] search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count ) {
+	return false;
+}
+
+static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc ** monitors, int count ) {
 
 	__thread_queue_t * entry_queue = &monitors[0]->entry_queue;
@@ -657,8 +655,8 @@
 		// For each acceptable check if it matches
 		int i;
-		__acceptable_t * acc_end = acceptables + acc_count;
-		for( __acceptable_t * acc_it = acceptables; acc_it != acc_end; acc_it++, i++ ) {
+		__acceptable_t * end = mask.clauses + mask.size;
+		for( __acceptable_t * it = mask.clauses; it != end; it++, i++ ) {
 			// Check if we have a match
-			if( acc_it->monitors == (*thrd_it)->monitors ) {
+			if( it->monitors == (*thrd_it)->monitors ) {
 
 				// If we have a match return it
@@ -672,22 +670,20 @@
 }
 
-static inline short count_max( short acc_count, __acceptable_t * acceptables ) {
+static inline short count_max( const __waitfor_mask_t & mask ) {
 	short max = 0;
-	for( int i = 0; i < acc_count; i++ ) {
-		max += acceptables[i].monitors.size;
+	for( int i = 0; i < mask.size; i++ ) {
+		max += mask.clauses[i].monitors.size;
 	}
 	return max;
 }
 
-static inline short aggregate( monitor_desc ** storage, short count, __acceptable_t * acceptables ) {
+static inline short aggregate( monitor_desc ** storage, const __waitfor_mask_t & mask ) {
 	#warning function not implemented
 	return 0;
 }
 
-static inline void set_mask( monitor_desc ** storage, short count, __acceptable_t * acceptables, short acc_count ) {
+static inline void set_mask( monitor_desc ** storage, short count, const __waitfor_mask_t & mask ) {
 	for(int i = 0; i < count; i++) {
-		storage[i]->acceptables      = acceptables;
-		storage[i]->acceptable_count = acc_count;
-		storage[i]->accepted_index   = -1;
+		storage[i]->mask = mask;
 	}
 }
