Index: src/libcfa/concurrency/coroutine
===================================================================
--- src/libcfa/concurrency/coroutine	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/coroutine	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -30,5 +30,5 @@
 };
 
-#define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->c; } void main(X* this)
+#define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->__cor; } void main(X* this)
 
 //-----------------------------------------------------------------------------
Index: src/libcfa/concurrency/invoke.c
===================================================================
--- src/libcfa/concurrency/invoke.c	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/invoke.c	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -29,5 +29,5 @@
 
 extern void __suspend_internal(void);
-extern void __thread_signal_termination(struct thread_desc*);
+extern void __leave_monitor_desc( struct monitor_desc * this );
 
 void CtxInvokeCoroutine(
@@ -56,4 +56,5 @@
 
 void CtxInvokeThread(
+      void (*dtor)(void *), 
       void (*main)(void *), 
       struct thread_desc *(*get_thread)(void *), 
@@ -63,5 +64,6 @@
 
       struct thread_desc* thrd = get_thread( this );
-      struct coroutine_desc* cor = &thrd->c;
+      struct coroutine_desc* cor = &thrd->cor;
+      struct monitor_desc* mon = &thrd->mon;
       cor->state = Active;
 
@@ -69,5 +71,5 @@
       main( this );
 
-      __thread_signal_termination(thrd);
+      __leave_monitor_desc( mon );
 
       //Final suspend, should never return
@@ -91,7 +93,7 @@
 	struct FakeStack {
 	    void *fixedRegisters[3];		  	// fixed registers ebx, edi, esi (popped on 1st uSwitch, values unimportant)
-	    uint32_t mxcr;                              // SSE Status and Control bits (control bits are preserved across function calls)
-            uint16_t fcw;                               // X97 FPU control word (preserved across function calls)
-	    void *rturn;                                // where to go on return from uSwitch
+	    uint32_t mxcr;                        // SSE Status and Control bits (control bits are preserved across function calls)
+          uint16_t fcw;                         // X97 FPU control word (preserved across function calls)
+	    void *rturn;                          // where to go on return from uSwitch
 	    void *dummyReturn;				// fake return compiler would have pushed on call to uInvoke
 	    void *argument[3];				// for 16-byte ABI, 16-byte alignment starts here
@@ -105,13 +107,15 @@
 	((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[0] = this;     // argument to invoke
 	((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke;
+      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520
+      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F;  //Vol. 1 8-7 
 
 #elif defined( __x86_64__ )
 
       struct FakeStack {
-            void *fixedRegisters[5];			// fixed registers rbx, r12, r13, r14, r15
-            uint32_t mxcr;                              // SSE Status and Control bits (control bits are preserved across function calls)
-            uint16_t fcw;                               // X97 FPU control word (preserved across function calls)
-            void *rturn;                                // where to go on return from uSwitch
-            void *dummyReturn;				// NULL return address to provide proper alignment
+            void *fixedRegisters[5];            // fixed registers rbx, r12, r13, r14, r15
+            uint32_t mxcr;                      // SSE Status and Control bits (control bits are preserved across function calls)
+            uint16_t fcw;                       // X97 FPU control word (preserved across function calls)
+            void *rturn;                        // where to go on return from uSwitch
+            void *dummyReturn;                  // NULL return address to provide proper alignment
       };
 
Index: src/libcfa/concurrency/invoke.h
===================================================================
--- src/libcfa/concurrency/invoke.h	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/invoke.h	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -28,5 +28,4 @@
       #define unlikely(x)    __builtin_expect(!!(x), 0)
       #define thread_local _Thread_local
-      #define SCHEDULER_CAPACITY 10
 
       struct spinlock {
@@ -39,10 +38,4 @@
       };
 
-      struct signal_once {
-            volatile bool condition;
-            struct spinlock lock;
-            struct simple_thread_list blocked;
-      };
-
       #ifdef __CFORALL__
       extern "Cforall" {
@@ -53,18 +46,15 @@
             void ?{}(spinlock * this);
             void ^?{}(spinlock * this);
-
-            void ?{}(signal_once * this);
-            void ^?{}(signal_once * this);
       }
       #endif
 
       struct coStack_t {
-            unsigned int size;		      // size of stack
-            void *storage;			      // pointer to stack
-            void *limit;			      // stack grows towards stack limit
-            void *base;				      // base of stack
-            void *context;			      // address of cfa_context_t
-            void *top;				      // address of top of storage
-            bool userStack;	
+            unsigned int size;                  // size of stack
+            void *storage;                      // pointer to stack
+            void *limit;                        // stack grows towards stack limit
+            void *base;                         // base of stack
+            void *context;                      // address of cfa_context_t
+            void *top;                          // address of top of storage
+            bool userStack;                     // whether or not the user allocated the stack
       };
 
@@ -72,16 +62,23 @@
 
       struct coroutine_desc {
-            struct coStack_t stack;
-            const char *name;			      // textual name for coroutine/task, initialized by uC++ generated code
-            int errno_;				      // copy of global UNIX variable errno
-            enum coroutine_state state;	      // current execution status for coroutine
-            struct coroutine_desc *starter;	      // first coroutine to resume this one
-            struct coroutine_desc *last;		      // last coroutine to resume this one
+            struct coStack_t stack;             // stack information of the coroutine
+            const char *name;                   // textual name for coroutine/task, initialized by uC++ generated code
+            int errno_;                         // copy of global UNIX variable errno
+            enum coroutine_state state;         // current execution status for coroutine
+            struct coroutine_desc *starter;     // first coroutine to resume this one
+            struct coroutine_desc *last;	      // last coroutine to resume this one
+      };
+
+      struct monitor_desc {
+            struct spinlock lock;
+            struct thread_desc * owner;
+            struct simple_thread_list entry_queue;
+            unsigned int recursion;
       };
 
       struct thread_desc {
-            struct coroutine_desc c;                 // coroutine body used to store context
-            struct signal_once terminated;      // indicate if execuation state is not halted
-            struct thread_desc * next;               // instrusive link field for threads
+            struct coroutine_desc cor;          // coroutine body used to store context
+            struct monitor_desc mon;            // monitor body used for mutual exclusion
+            struct thread_desc * next;          // instrusive link field for threads
       };
 
Index: src/libcfa/concurrency/kernel
===================================================================
--- src/libcfa/concurrency/kernel	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/kernel	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -30,4 +30,13 @@
 void lock( spinlock * );
 void unlock( spinlock * );
+
+struct signal_once {
+	volatile bool condition;
+	struct spinlock lock;
+	struct simple_thread_list blocked;
+};
+
+void ?{}(signal_once * this);
+void ^?{}(signal_once * this);
 
 void wait( signal_once * );
Index: src/libcfa/concurrency/kernel.c
===================================================================
--- src/libcfa/concurrency/kernel.c	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/kernel.c	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -107,5 +107,5 @@
 
 void ?{}( thread_desc * this, current_stack_info_t * info) {
-	(&this->c){ info };
+	(&this->cor){ info };
 }
 
@@ -113,5 +113,5 @@
 // Processor coroutine
 void ?{}(processorCtx_t * this, processor * proc) {
-	(&this->c){};
+	(&this->__cor){};
 	this->proc = proc;
 	proc->runner = this;
@@ -119,5 +119,5 @@
 
 void ?{}(processorCtx_t * this, processor * proc, current_stack_info_t * info) {
-	(&this->c){ info };
+	(&this->__cor){ info };
 	this->proc = proc;
 	proc->runner = this;
@@ -255,8 +255,8 @@
 	processorCtx_t proc_cor_storage = { proc, &info };
 
-	LIB_DEBUG_PRINTF("Coroutine : created stack %p\n", proc_cor_storage.c.stack.base);
+	LIB_DEBUG_PRINTF("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);
 
 	//Set global state
-	proc->current_coroutine = &proc->runner->c;
+	proc->current_coroutine = &proc->runner->__cor;
 	proc->current_thread = NULL;
 
@@ -268,7 +268,7 @@
 	// back to here. Instead directly call the main since we already are on the 
 	// appropriate stack.
-	proc_cor_storage.c.state = Active;
+	proc_cor_storage.__cor.state = Active;
       main( &proc_cor_storage );
-      proc_cor_storage.c.state = Halted;
+      proc_cor_storage.__cor.state = Halted;
 
 	// Main routine of the core returned, the core is now fully terminated
@@ -359,5 +359,5 @@
 	this_processor = systemProcessor;
 	this_processor->current_thread = mainThread;
-	this_processor->current_coroutine = &mainThread->c;
+	this_processor->current_coroutine = &mainThread->cor;
 
 	// SKULLDUGGERY: Force a context switch to the system processor to set the main thread's context to the current UNIX
Index: src/libcfa/concurrency/kernel_private.h
===================================================================
--- src/libcfa/concurrency/kernel_private.h	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/kernel_private.h	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -35,5 +35,5 @@
 struct processorCtx_t {
 	processor * proc;
-	coroutine_desc c;
+	coroutine_desc __cor;
 };
 
Index: src/libcfa/concurrency/monitor
===================================================================
--- src/libcfa/concurrency/monitor	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/monitor	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -22,19 +22,8 @@
 #include "stdlib"
 
-struct monitor_desc {
-	spinlock lock;
-	thread_desc * owner;
-	simple_thread_list entry_queue;
-	unsigned int recursion;
-};
-
 static inline void ?{}(monitor_desc * this) {
 	this->owner = 0;
 	this->recursion = 0;
 }
-
-//Basic entering routine
-void enter(monitor_desc *);
-void leave(monitor_desc *);
 
 //Array entering routine
@@ -49,10 +38,4 @@
 static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) {
 	return ((intptr_t)lhs) < ((intptr_t)rhs);
-}
-
-static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) {
-	this->m = m;
-	this->count = 1;
-	enter( *this->m );
 }
 
Index: src/libcfa/concurrency/monitor.c
===================================================================
--- src/libcfa/concurrency/monitor.c	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/monitor.c	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -19,54 +19,56 @@
 #include "kernel_private.h"
 
-void enter(monitor_desc * this) {
-	lock( &this->lock );
-	thread_desc * thrd = this_thread();
+extern "C" {
+	void __enter_monitor_desc(monitor_desc * this) {
+		lock( &this->lock );
+		thread_desc * thrd = this_thread();
 
-	if( !this->owner ) {
-		//No one has the monitor, just take it
-		this->owner = thrd;
-		this->recursion = 1;
-	}
-	else if( this->owner == thrd) {
-		//We already have the monitor, just not how many times we took it
-		assert( this->recursion > 0 );
-		this->recursion += 1;
-	}
-	else {
-		//Some one else has the monitor, wait in line for it
-		append( &this->entry_queue, thrd );
-		ScheduleInternal( &this->lock );
+		if( !this->owner ) {
+			//No one has the monitor, just take it
+			this->owner = thrd;
+			this->recursion = 1;
+		}
+		else if( this->owner == thrd) {
+			//We already have the monitor, just not how many times we took it
+			assert( this->recursion > 0 );
+			this->recursion += 1;
+		}
+		else {
+			//Some one else has the monitor, wait in line for it
+			append( &this->entry_queue, thrd );
+			ScheduleInternal( &this->lock );
 
-		//ScheduleInternal will unlock spinlock, no need to unlock ourselves
-		return; 
+			//ScheduleInternal will unlock spinlock, no need to unlock ourselves
+			return; 
+		}
+
+		unlock( &this->lock );
 	}
 
-	unlock( &this->lock );
-}
+	void __leave_monitor_desc(monitor_desc * this) {
+		lock( &this->lock );
 
-void leave(monitor_desc * this) {
-	lock( &this->lock );
+		thread_desc * thrd = this_thread();
+		assert( thrd == this->owner );
 
-	thread_desc * thrd = this_thread();
-	assert( thrd == this->owner );
+		//Leaving a recursion level, decrement the counter
+		this->recursion -= 1;
 
-	//Leaving a recursion level, decrement the counter
-	this->recursion -= 1;
+		//If we left the last level of recursion it means we are changing who owns the monitor
+		thread_desc * new_owner = 0;
+		if( this->recursion == 0) {
+			//Get the next thread in the list
+			new_owner = this->owner = pop_head( &this->entry_queue );
 
-	//If we left the last level of recursion it means we are changing who owns the monitor
-	thread_desc * new_owner = 0;
-	if( this->recursion == 0) {
-		//Get the next thread in the list
-		new_owner = this->owner = pop_head( &this->entry_queue );
+			//We are passing the monitor to someone else, which means recursion level is not 0
+			this->recursion = new_owner ? 1 : 0;
+		}	
 
-		//We are passing the monitor to someone else, which means recursion level is not 0
-		this->recursion = new_owner ? 1 : 0;
-	}	
+		unlock( &this->lock );
 
-	unlock( &this->lock );
-
-	//If we have a new owner, we need to wake-up the thread
-	if( new_owner ) {
-		ScheduleThread( new_owner );
+		//If we have a new owner, we need to wake-up the thread
+		if( new_owner ) {
+			ScheduleThread( new_owner );
+		}
 	}
 }
@@ -74,6 +76,5 @@
 void enter(monitor_desc ** monitors, int count) {
 	for(int i = 0; i < count; i++) {
-		// printf("%d\n", i);
-		enter( monitors[i] );
+		__enter_monitor_desc( monitors[i] );
 	}
 }
@@ -81,6 +82,5 @@
 void leave(monitor_desc ** monitors, int count) {
 	for(int i = count - 1; i >= 0; i--) {
-		// printf("%d\n", i);
-		leave( monitors[i] );
+		__leave_monitor_desc( monitors[i] );
 	}
 }
Index: src/libcfa/concurrency/thread
===================================================================
--- src/libcfa/concurrency/thread	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/thread	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -22,4 +22,5 @@
 
 #include "coroutine"
+#include "monitor"
 
 //-----------------------------------------------------------------------------
@@ -28,17 +29,27 @@
 // Anything that is resumed is a coroutine.
 trait is_thread(dtype T) {
+      void ^?{}(T* mutex this);
       void main(T* this);
       thread_desc* get_thread(T* this);
 };
 
-#define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->t; } void main(X* this)
+#define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->__thrd; } void main(X* this)
 
 forall( dtype T | is_thread(T) )
 static inline coroutine_desc* get_coroutine(T* this) {
-	return &get_thread(this)->c;
+	return &get_thread(this)->cor;
 }
 
-static inline coroutine_desc* get_coroutine(thread_desc* this) {
-	return &this->c;
+forall( dtype T | is_thread(T) )
+static inline monitor_desc* get_monitor(T * this) {
+	return &get_thread(this)->mon;
+}
+
+static inline coroutine_desc* get_coroutine(thread_desc * this) {
+	return &this->cor;
+}
+
+static inline monitor_desc* get_monitor(thread_desc * this) {
+	return &this->mon;
 }
 
@@ -64,5 +75,5 @@
 void ?{}( scoped(T)* this, P params );
 
-forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } )
+forall( dtype T | sized(T) | is_thread(T) )
 void ^?{}( scoped(T)* this );
 
Index: src/libcfa/concurrency/thread.c
===================================================================
--- src/libcfa/concurrency/thread.c	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/concurrency/thread.c	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -35,19 +35,17 @@
 void start( T* this );
 
-forall( dtype T | is_thread(T) )
-void stop( T* this );
-
 //-----------------------------------------------------------------------------
 // Thread ctors and dtors
 
 void ?{}(thread_desc* this) {
-	(&this->c){};
-	this->c.name = "Anonymous Coroutine";
-	(&this->terminated){};
+	(&this->cor){};
+	this->cor.name = "Anonymous Coroutine";
+	this->mon.owner = this;
+	this->mon.recursion = 1;
 	this->next = NULL;
 }
 
 void ^?{}(thread_desc* this) {
-	^(&this->c){};
+	^(&this->cor){};
 }
 
@@ -64,7 +62,6 @@
 }
 
-forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } )
+forall( dtype T | sized(T) | is_thread(T) )
 void ^?{}( scoped(T)* this ) {
-	stop(&this->handle);
 	^(&this->handle){};
 }
@@ -86,9 +83,4 @@
 
 	ScheduleThread(thrd_h);
-}
-
-forall( dtype T | is_thread(T) )
-void stop( T* this ) {
-	wait( & get_thread(this)->terminated );	
 }
 
@@ -116,14 +108,4 @@
 }
 
-// C Helper to signal the termination of a thread_desc
-// Used in invoke.c
-extern "C" {
-	void __thread_signal_termination( thread_desc * this ) {
-		this->c.state = Halted;
-		LIB_DEBUG_PRINTF("Thread end : %p\n", this);
-		signal( &this->terminated );	
-	}
-}
-
 // Local Variables: //
 // mode: c //
Index: src/libcfa/iostream.c
===================================================================
--- src/libcfa/iostream.c	(revision 829c907247aaf3211ea7e8c3d290193a6f2d15d5)
+++ src/libcfa/iostream.c	(revision 87d13cd6f0b6eede5621fb0f5bd5b06911c656fe)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Mar 21 20:58:48 2017
-// Update Count     : 347
+// Last Modified On : Tue Mar 21 22:05:57 2017
+// Update Count     : 348
 //
 
