Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/CodeGenerator.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,26 +14,24 @@
 //
 
-#include <algorithm>
-#include <iostream>
-#include <cassert>
-#include <list>
-
-#include "Parser/ParseNode.h"
-
-#include "SynTree/Declaration.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Initializer.h"
-#include "SynTree/Statement.h"
-#include "SynTree/Type.h"
-#include "SynTree/Attribute.h"
-
-#include "Common/utility.h"
-#include "Common/UnimplementedError.h"
+#include <cassert>                   // for assert, assertf
+#include <list>                      // for _List_iterator, list, list<>::it...
 
 #include "CodeGenerator.h"
-#include "OperatorTable.h"
-#include "GenType.h"
-
-#include "InitTweak/InitTweak.h"
+#include "Common/SemanticError.h"    // for SemanticError
+#include "Common/UniqueName.h"       // for UniqueName
+#include "Common/utility.h"          // for CodeLocation, toString
+#include "GenType.h"                 // for genType
+#include "InitTweak/InitTweak.h"     // for getPointerBase
+#include "OperatorTable.h"           // for OperatorInfo, operatorLookup
+#include "Parser/LinkageSpec.h"      // for Spec, Intrinsic
+#include "SynTree/Attribute.h"       // for Attribute
+#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
+#include "SynTree/Constant.h"        // for Constant
+#include "SynTree/Declaration.h"     // for DeclarationWithType, TypeDecl
+#include "SynTree/Expression.h"      // for Expression, UntypedExpr, Applica...
+#include "SynTree/Initializer.h"     // for Initializer, ListInit, Designation
+#include "SynTree/Label.h"           // for Label, operator<<
+#include "SynTree/Statement.h"       // for Statement, AsmStmt, BranchStmt
+#include "SynTree/Type.h"            // for Type, Type::StorageClasses, Func...
 
 using namespace std;
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/CodeGenerator.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,14 +17,11 @@
 #define CODEGENV_H
 
-#include <list>
+#include <list>                   // for list
+#include <ostream>                // for ostream, operator<<
+#include <string>                 // for string
 
-#include "SynTree/Declaration.h"
-#include "SynTree/SynTree.h"
-#include "SynTree/Visitor.h"
-
-#include "SymTab/Indexer.h"
-
-#include "Common/Indenter.h"
-#include "Common/utility.h"
+#include "SynTree/Declaration.h"  // for DeclarationWithType (ptr only), Fun...
+#include "SynTree/Visitor.h"      // for Visitor
+#include "SynTree/SynTree.h"      // for Visitor Nodes
 
 namespace CodeGen {
Index: src/CodeGen/FixMain.cc
===================================================================
--- src/CodeGen/FixMain.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/FixMain.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -5,30 +5,33 @@
 // file "LICENCE" distributed with Cforall.
 //
-// FixMain.cc -- 
+// FixMain.cc --
 //
 // Author           : Thierry Delisle
 // Created On       : Thr Jan 12 14:11:09 2017
-// Last Modified By : 
-// Last Modified On : 
+// Last Modified By :
+// Last Modified On :
 // Update Count     : 0
 //
 
 
-#include "FixMain.h"	
+#include "FixMain.h"
 
-#include <fstream>
-#include <iostream>
+#include <cassert>                 // for assert, assertf
+#include <fstream>                 // for operator<<, basic_ostream::operator<<
+#include <list>                    // for list
+#include <string>                  // for operator<<
 
-#include "Common/SemanticError.h"
-#include "SynTree/Declaration.h"
+#include "Common/SemanticError.h"  // for SemanticError
+#include "SynTree/Declaration.h"   // for FunctionDecl, operator<<
+#include "SynTree/Type.h"          // for FunctionType
 
 namespace CodeGen {
 	bool FixMain::replace_main = false;
 	std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr;
-	
-	void FixMain::registerMain(FunctionDecl* functionDecl) 
+
+	void FixMain::registerMain(FunctionDecl* functionDecl)
 	{
-		if(main_signature) { 
-			throw SemanticError("Multiple definition of main routine\n", functionDecl); 
+		if(main_signature) {
+			throw SemanticError("Multiple definition of main routine\n", functionDecl);
 		}
 		main_signature.reset( functionDecl->clone() );
Index: src/CodeGen/FixNames.cc
===================================================================
--- src/CodeGen/FixNames.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/FixNames.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,13 +14,20 @@
 //
 
-#include <memory>
+#include "FixNames.h"
 
-#include "FixNames.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Visitor.h"
-#include "SymTab/Mangler.h"
-#include "OperatorTable.h"
-#include "FixMain.h"
+#include <memory>                  // for unique_ptr
+#include <string>                  // for string, operator!=, operator==
+
+#include "Common/SemanticError.h"  // for SemanticError
+#include "FixMain.h"               // for FixMain
+#include "Parser/LinkageSpec.h"    // for Cforall, isMangled
+#include "SymTab/Mangler.h"        // for Mangler
+#include "SynTree/Constant.h"      // for Constant
+#include "SynTree/Declaration.h"   // for FunctionDecl, ObjectDecl, Declarat...
+#include "SynTree/Expression.h"    // for ConstantExpr
+#include "SynTree/Label.h"         // for Label, noLabels
+#include "SynTree/Statement.h"     // for ReturnStmt, CompoundStmt
+#include "SynTree/Type.h"          // for Type, BasicType, Type::Qualifiers
+#include "SynTree/Visitor.h"       // for Visitor, acceptAll
 
 namespace CodeGen {
@@ -42,5 +49,5 @@
 																   main_type = new FunctionType( Type::Qualifiers(), true ), nullptr )
 				};
-		main_type->get_returnVals().push_back( 
+		main_type->get_returnVals().push_back(
 			new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
 		);
@@ -52,18 +59,18 @@
 	std::string mangle_main_args() {
 		FunctionType* main_type;
-		std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 
+		std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
 																   main_type = new FunctionType( Type::Qualifiers(), false ), nullptr )
 				};
-		main_type->get_returnVals().push_back( 
+		main_type->get_returnVals().push_back(
 			new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
 		);
 
-		mainDecl->get_functionType()->get_parameters().push_back( 
+		mainDecl->get_functionType()->get_parameters().push_back(
 			new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
 		);
 
-		mainDecl->get_functionType()->get_parameters().push_back( 
-			new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 
-			new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 
+		mainDecl->get_functionType()->get_parameters().push_back(
+			new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0,
+			new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ),
 			nullptr )
 		);
@@ -75,6 +82,6 @@
 
 	bool is_main(const std::string& name) {
-		static std::string mains[] = { 
-			mangle_main(), 
+		static std::string mains[] = {
+			mangle_main(),
 			mangle_main_args()
 		};
@@ -112,5 +119,5 @@
 			int nargs = functionDecl->get_functionType()->get_parameters().size();
 			if( !(nargs == 0 || nargs == 2 || nargs == 3) ) {
-				throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 
+				throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
 			}
 			functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
Index: src/CodeGen/FixNames.h
===================================================================
--- src/CodeGen/FixNames.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/FixNames.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,5 +17,7 @@
 #define FIXNAMES_H
 
-#include "SynTree/SynTree.h"
+#include <list>  // for list
+
+class Declaration;
 
 namespace CodeGen {
Index: src/CodeGen/GenType.cc
===================================================================
--- src/CodeGen/GenType.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/GenType.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,14 +14,14 @@
 //
 
-#include <sstream>
-#include <cassert>
-
+#include <cassert>                // for assert, assertf
+#include <list>                   // for _List_iterator, _List_const_iterator
+#include <sstream>                // for operator<<, ostringstream, basic_os...
+
+#include "CodeGenerator.h"        // for CodeGenerator
 #include "GenType.h"
-#include "CodeGenerator.h"
-
-#include "SynTree/Declaration.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Type.h"
-#include "SynTree/Visitor.h"
+#include "SynTree/Declaration.h"  // for DeclarationWithType
+#include "SynTree/Expression.h"   // for Expression
+#include "SynTree/Type.h"         // for PointerType, Type, FunctionType
+#include "SynTree/Visitor.h"      // for Visitor
 
 namespace CodeGen {
Index: src/CodeGen/GenType.h
===================================================================
--- src/CodeGen/GenType.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/GenType.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,6 +17,7 @@
 #define _GENTYPE_H
 
-#include <string>
-#include "SynTree/SynTree.h"
+#include <string>  // for string
+
+class Type;
 
 namespace CodeGen {
Index: src/CodeGen/Generate.cc
===================================================================
--- src/CodeGen/Generate.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/Generate.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,17 +14,15 @@
 //
 
-#include <algorithm>
-#include <iostream>
-#include <cassert>
-#include <list>
+#include <iostream>                  // for ostream, endl, operator<<
+#include <list>                      // for list
+#include <string>                    // for operator<<
 
+#include "CodeGenerator.h"           // for CodeGenerator, doSemicolon, oper...
+#include "GenType.h"                 // for genPrettyType
 #include "Generate.h"
-#include "SynTree/Declaration.h"
-#include "CodeGenerator.h"
-#include "GenType.h"
-#include "SynTree/SynTree.h"
-#include "SynTree/Type.h"
-#include "SynTree/BaseSyntaxNode.h"
-// #include "Tuples/Tuples.h"
+#include "Parser/LinkageSpec.h"      // for isBuiltin, isGeneratable
+#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
+#include "SynTree/Declaration.h"     // for Declaration
+#include "SynTree/Type.h"            // for Type
 
 using namespace std;
Index: src/CodeGen/Generate.h
===================================================================
--- src/CodeGen/Generate.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/Generate.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,8 +17,9 @@
 #define GENERATE_H
 
-#include <list>
-#include <iostream>
+#include <iostream>  // for ostream
+#include <list>      // for list
 
-#include "SynTree/SynTree.h"
+class BaseSyntaxNode;
+class Declaration;
 
 namespace CodeGen {
Index: src/CodeGen/OperatorTable.cc
===================================================================
--- src/CodeGen/OperatorTable.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeGen/OperatorTable.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,5 +14,7 @@
 //
 
-#include <map>
+#include <map>      // for map, _Rb_tree_const_iterator, map<>::const_iterator
+#include <utility>  // for pair
+
 #include "OperatorTable.h"
 
Index: src/CodeTools/DeclStats.cc
===================================================================
--- src/CodeTools/DeclStats.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeTools/DeclStats.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -16,19 +16,23 @@
 #include "DeclStats.h"
 
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <string>
-#include <unordered_map>
-#include <unordered_set>
-
-#include "Common/VectorMap.h"
-#include "GenPoly/GenPoly.h"
-#include "Parser/LinkageSpec.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Visitor.h"
+#include <iostream>                // for operator<<, basic_ostream, cout
+#include <map>                     // for map
+#include <string>                  // for string, operator+, operator<<, cha...
+#include <unordered_map>           // for unordered_map
+#include <unordered_set>           // for unordered_set
+#include <utility>                 // for pair, make_pair
+
+#include "Common/SemanticError.h"  // for SemanticError
+#include "Common/VectorMap.h"      // for VectorMap
+#include "GenPoly/GenPoly.h"       // for hasPolyBase
+#include "Parser/LinkageSpec.h"    // for ::NoOfSpecs, Spec
+#include "SynTree/Declaration.h"   // for FunctionDecl, TypeDecl, Declaration
+#include "SynTree/Expression.h"    // for UntypedExpr, Expression
+#include "SynTree/Statement.h"     // for CompoundStmt
+#include "SynTree/Type.h"          // for Type, FunctionType, PointerType
+#include "SynTree/Visitor.h"       // for maybeAccept, Visitor, acceptAll
 
 namespace CodeTools {
-	
+
 	class DeclStats : public Visitor {
 		template<typename T>
@@ -75,9 +79,9 @@
 				sum(n_types, o.n_types);
 				sum(p_new, o.p_new);
-				
+
 				return *this;
 			}
 		};
-		
+
 		struct Stats {
 			unsigned n_decls;     ///< Total number of declarations
@@ -98,5 +102,5 @@
 			/// Stats for the return list
 			ArgPackStats returns;
-			
+
 			/// Count of declarations with each number of assertions
 			std::map<unsigned, unsigned> n_assns;
@@ -105,5 +109,5 @@
 			/// Stats for the assertions' return types
 			ArgPackStats assn_returns;
-			
+
 			Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), basic_type_decls(), compound_type_decls(), params(), returns(), n_assns(), assn_params(), assn_returns() {}
 
@@ -122,5 +126,5 @@
 				sum( assn_params, o.assn_params );
 				sum( assn_returns, o.assn_returns );
-				
+
 				return *this;
 			}
@@ -144,5 +148,5 @@
 
 				n += dt->size();
-				
+
 				std::stringstream ss;
 				dt->print( ss );
@@ -176,5 +180,5 @@
 			++pstats.n_types.at( types.size() );
 		}
-		
+
 		void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) {
 			std::unordered_set<std::string> seen;
@@ -186,5 +190,5 @@
 			auto& args = expr->get_args();
 			unsigned fanout = args.size();
-			
+
 			++exprs_by_fanout_at_depth[ std::make_pair(depth, fanout) ];
 			for ( Expression* arg : args ) {
@@ -205,5 +209,5 @@
 				return;
 			}
-			
+
 			Stats& stats = for_linkage[ decl->get_linkage() ];
 
@@ -323,13 +327,13 @@
 		}
 
-		void printPairMap( const std::string& name, 
+		void printPairMap( const std::string& name,
 		                   const std::map<std::pair<unsigned, unsigned>, unsigned>& map ) {
 			for ( const auto& entry : map ) {
 				const auto& key = entry.first;
-				std::cout << "\"" << name << "\"," << key.first << "," << key.second << "," 
+				std::cout << "\"" << name << "\"," << key.first << "," << key.second << ","
 				          << entry.second << std::endl;
 			}
 		}
-		
+
 	public:
 		void print() {
@@ -366,5 +370,5 @@
 		stats.print();
 	}
-	
+
 } // namespace CodeTools
 
Index: src/CodeTools/DeclStats.h
===================================================================
--- src/CodeTools/DeclStats.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeTools/DeclStats.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,5 +17,7 @@
 #define DECLSTATS_H
 
-#include "SynTree/SynTree.h"
+#include <list>  // for list
+
+class Declaration;
 
 namespace CodeTools {
Index: src/CodeTools/TrackLoc.cc
===================================================================
--- src/CodeTools/TrackLoc.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeTools/TrackLoc.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -16,19 +16,20 @@
 #include "TrackLoc.h"
 
-#include <cstdlib>
+#include <cstdlib>                    // for size_t, exit, EXIT_FAILURE
+#include <iostream>                   // for operator<<, ostream, basic_ostream
+#include <iterator>                   // for back_inserter, inserter
+#include <stack>                      // for stack
+#include <string>                     // for operator<<, string
+#include <typeindex>                  // for type_index
 
-#include <iostream>
-#include <sstream>
-#include <stack>
-#include <string>
-#include <typeindex>
+#include "Common/PassVisitor.h"       // for PassVisitor
+#include "Common/PassVisitor.impl.h"  // for acceptAll
+#include "Common/SemanticError.h"     // for SemanticError
+#include "Common/utility.h"           // for CodeLocation
+#include "SynTree/BaseSyntaxNode.h"   // for BaseSyntaxNode
+#include "SynTree/Mutator.h"          // for mutateAll
+#include "SynTree/Visitor.h"          // for acceptAll
 
-#include "Common/utility.h"
-#include "Common/PassVisitor.h"
-#include "Common/VectorMap.h"
-#include "GenPoly/GenPoly.h"
-#include "Parser/LinkageSpec.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Initializer.h"
+class Declaration;
 
 namespace CodeTools {
Index: src/CodeTools/TrackLoc.h
===================================================================
--- src/CodeTools/TrackLoc.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/CodeTools/TrackLoc.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,5 +17,8 @@
 #define TRACKLOC_H
 
-#include "SynTree/SynTree.h"
+#include <cstddef>   // for size_t
+#include <list>      // for list
+
+class Declaration;
 
 namespace CodeTools {
Index: src/Common/Assert.cc
===================================================================
--- src/Common/Assert.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Common/Assert.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,8 +14,7 @@
 //
 
-#include <assert.h>
-#include <cstdarg>										// varargs
-#include <cstdio>										// fprintf
-#include <cstdlib>										// abort
+#include <cstdarg>  // for va_end, va_list, va_start
+#include <cstdio>   // for fprintf, stderr, vfprintf
+#include <cstdlib>  // for abort
 
 extern const char * __progname;							// global name of running executable (argv[0])
Index: src/Common/SemanticError.cc
===================================================================
--- src/Common/SemanticError.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Common/SemanticError.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -14,13 +14,12 @@
 //
 
-#include <iostream>
-#include <list>
-#include <string>
-#include <algorithm>
-#include <iterator>
+#include <cstdio>            // for fileno, stderr
+#include <unistd.h>          // for isatty
+#include <iostream>          // for basic_ostream, operator<<, ostream
+#include <list>              // for list, _List_iterator
+#include <string>            // for string, operator<<, operator+, to_string
 
+#include "Common/utility.h"  // for to_string, CodeLocation (ptr only)
 #include "SemanticError.h"
-
-#include <unistd.h>
 
 inline const std::string& error_str() {
Index: src/Common/SemanticError.h
===================================================================
--- src/Common/SemanticError.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Common/SemanticError.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,11 +17,10 @@
 #define SEMANTICERROR_H
 
-#include <exception>
-#include <string>
-#include <sstream>
-#include <list>
-#include <iostream>
+#include <exception>  // for exception
+#include <iostream>   // for ostream
+#include <list>       // for list
+#include <string>     // for string
 
-#include "utility.h"
+#include "utility.h"  // for CodeLocation, toString
 
 struct error {
Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Concurrency/Keywords.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,12 +17,22 @@
 #include "Concurrency/Keywords.h"
 
-#include "InitTweak/InitTweak.h"
-#include "SymTab/AddVisit.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Initializer.h"
-#include "SynTree/Statement.h"
-#include "SynTree/Type.h"
-#include "SynTree/Visitor.h"
+#include <cassert>                 // for assert
+#include <string>                  // for string, operator==
+
+#include "Common/SemanticError.h"  // for SemanticError
+#include "Common/utility.h"        // for deleteAll, map_range
+#include "InitTweak/InitTweak.h"   // for isConstructor
+#include "Parser/LinkageSpec.h"    // for Cforall
+#include "SymTab/AddVisit.h"       // for acceptAndAdd
+#include "SynTree/Constant.h"      // for Constant
+#include "SynTree/Declaration.h"   // for StructDecl, FunctionDecl, ObjectDecl
+#include "SynTree/Expression.h"    // for VariableExpr, ConstantExpr, Untype...
+#include "SynTree/Initializer.h"   // for SingleInit, ListInit, Initializer ...
+#include "SynTree/Label.h"         // for Label
+#include "SynTree/Statement.h"     // for CompoundStmt, DeclStmt, ExprStmt
+#include "SynTree/Type.h"          // for StructInstType, Type, PointerType
+#include "SynTree/Visitor.h"       // for Visitor, acceptAll
+
+class Attribute;
 
 namespace Concurrency {
@@ -322,5 +332,5 @@
 		if( needs_main ) {
 			FunctionType * main_type = new FunctionType( noQualifiers, false );
-			
+
 			main_type->get_parameters().push_back( this_decl->clone() );
 
@@ -361,5 +371,5 @@
 	void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) {
 		CompoundStmt * statement = new CompoundStmt( noLabels );
-		statement->push_back( 
+		statement->push_back(
 			new ReturnStmt(
 				noLabels,
@@ -386,5 +396,5 @@
 	//=============================================================================================
 	void MutexKeyword::visit(FunctionDecl* decl) {
-		Visitor::visit(decl);		
+		Visitor::visit(decl);
 
 		std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
@@ -510,5 +520,5 @@
 	void ThreadStarter::visit(FunctionDecl * decl) {
 		Visitor::visit(decl);
-		
+
 		if( ! InitTweak::isConstructor(decl->get_name()) ) return;
 
@@ -528,5 +538,5 @@
 		if( ! stmt ) return;
 
-		stmt->push_back( 
+		stmt->push_back(
 			new ExprStmt(
 				noLabels,
Index: src/Concurrency/Keywords.h
===================================================================
--- src/Concurrency/Keywords.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Concurrency/Keywords.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -18,7 +18,7 @@
 #define KEYWORDS_H
 
-#include <list>
+#include <list>  // for list
 
-#include "SynTree/Declaration.h"
+class Declaration;
 
 namespace Concurrency {
Index: src/ControlStruct/ExceptTranslate.cc
===================================================================
--- src/ControlStruct/ExceptTranslate.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/ControlStruct/ExceptTranslate.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Jun 14 16:49:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Jun 30 13:30:00 2017
-// Update Count     : 1
+// Last Modified On : Wed Jul 12 15:07:00 2017
+// Update Count     : 3
 //
 
@@ -157,5 +157,5 @@
 	Statement * create_terminate_throw( ThrowStmt *throwStmt ) {
 		// { int NAME = EXPR; __throw_terminate( &NAME ); }
-		return create_given_throw( "__cfaehm__throw_termination", throwStmt );
+		return create_given_throw( "__cfaehm__throw_terminate", throwStmt );
 	}
 	Statement * create_terminate_rethrow( ThrowStmt *throwStmt ) {
@@ -164,5 +164,5 @@
 		Statement * result = new ExprStmt(
 			throwStmt->get_labels(),
-			new UntypedExpr( new NameExpr( "__cfaehm__rethrow_termination" ) )
+			new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) )
 			);
 		delete throwStmt;
@@ -171,5 +171,5 @@
 	Statement * create_resume_throw( ThrowStmt *throwStmt ) {
 		// __throw_resume( EXPR );
-		return create_given_throw( "__cfaehm__throw_resumption", throwStmt );
+		return create_given_throw( "__cfaehm__throw_resume", throwStmt );
 	}
 	Statement * create_resume_rethrow( ThrowStmt *throwStmt ) {
@@ -593,7 +593,5 @@
 
 		PassVisitor<ExceptionMutatorCore> translator;
-		for ( Declaration * decl : translationUnit ) {
-			decl->acceptMutator( translator );
-		}
+		mutateAll( translationUnit, translator );
 	}
 }
Index: src/GenPoly/InstantiateGeneric.cc
===================================================================
--- src/GenPoly/InstantiateGeneric.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/GenPoly/InstantiateGeneric.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -171,5 +171,5 @@
 		Type* postmutate( UnionInstType *inst );
 
-		void premutate( FunctionType * ftype ) {
+		void premutate( __attribute__((unused)) FunctionType * ftype ) {
 			GuardValue( inFunctionType );
 			inFunctionType = true;
Index: src/InitTweak/GenInit.cc
===================================================================
--- src/InitTweak/GenInit.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/InitTweak/GenInit.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -71,11 +71,10 @@
 		// that need to be constructed or destructed
 		void previsit( StructDecl *aggregateDecl );
-		void previsit( UnionDecl *aggregateDecl ) { visit_children = false; }
-		void previsit( EnumDecl *aggregateDecl ) { visit_children = false; }
-		void previsit( TraitDecl *aggregateDecl ) { visit_children = false; }
-		void previsit( TypeDecl *typeDecl ) { visit_children = false; }
-		void previsit( TypedefDecl *typeDecl ) { visit_children = false; }
-
-		void previsit( FunctionType *funcType ) { visit_children = false; }
+		void previsit( __attribute__((unused)) UnionDecl    * aggregateDecl ) { visit_children = false; }
+		void previsit( __attribute__((unused)) EnumDecl     * aggregateDecl ) { visit_children = false; }
+		void previsit( __attribute__((unused)) TraitDecl    * aggregateDecl ) { visit_children = false; }
+		void previsit( __attribute__((unused)) TypeDecl     * typeDecl )      { visit_children = false; }
+		void previsit( __attribute__((unused)) TypedefDecl  * typeDecl )      { visit_children = false; }
+		void previsit( __attribute__((unused)) FunctionType * funcType )      { visit_children = false; }
 
 		void previsit( CompoundStmt * compoundStmt );
@@ -336,5 +335,5 @@
 	}
 
-	void CtorDtor::previsit( CompoundStmt * compoundStmt ) {
+	void CtorDtor::previsit( __attribute__((unused)) CompoundStmt * compoundStmt ) {
 		GuardScope( managedTypes );
 	}
Index: src/MakeLibCfa.cc
===================================================================
--- src/MakeLibCfa.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/MakeLibCfa.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -15,12 +15,19 @@
 
 #include "MakeLibCfa.h"
-#include "SynTree/Visitor.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Type.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Statement.h"
-#include "SynTree/Initializer.h"
-#include "CodeGen/OperatorTable.h"
-#include "Common/UniqueName.h"
+
+#include <cassert>                 // for assert
+#include <string>                   // for operator==, string
+
+#include "CodeGen/OperatorTable.h"  // for OperatorInfo, operatorLookup, Ope...
+#include "Common/SemanticError.h"   // for SemanticError
+#include "Common/UniqueName.h"      // for UniqueName
+#include "Parser/LinkageSpec.h"     // for Spec, Intrinsic, C
+#include "SynTree/Declaration.h"    // for FunctionDecl, ObjectDecl, Declara...
+#include "SynTree/Expression.h"     // for NameExpr, UntypedExpr, VariableExpr
+#include "SynTree/Initializer.h"    // for SingleInit
+#include "SynTree/Label.h"          // for Label
+#include "SynTree/Statement.h"      // for CompoundStmt, ReturnStmt
+#include "SynTree/Type.h"           // for FunctionType
+#include "SynTree/Visitor.h"        // for acceptAll, Visitor
 
 namespace LibCfa {
Index: src/MakeLibCfa.h
===================================================================
--- src/MakeLibCfa.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/MakeLibCfa.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,6 +17,7 @@
 #define LIBCFA_MAKELIBCFA_H
 
-#include <list>
-#include <SynTree/SynTree.h>
+#include <list>  // for list
+
+class Declaration;
 
 namespace LibCfa {
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Makefile.am	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -43,5 +43,5 @@
 driver_cfa_cpp_SOURCES = ${SRC}
 driver_cfa_cpp_LDADD = ${LEXLIB} -ldl			# yywrap
-driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
+driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
 
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -544,5 +544,5 @@
 driver_cfa_cpp_SOURCES = ${SRC}
 driver_cfa_cpp_LDADD = ${LEXLIB} -ldl			# yywrap
-driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
+driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
 all: $(BUILT_SOURCES)
@@ -560,7 +560,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/Makefile
+	  $(AUTOMAKE) --foreign src/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/Parser/LinkageSpec.cc
===================================================================
--- src/Parser/LinkageSpec.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Parser/LinkageSpec.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 13:22:09 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Jun 28 11:51:00 2017
-// Update Count     : 24
+// Last Modified On : Fri Jul  7 11:11:00 2017
+// Update Count     : 25
 //
 
@@ -22,5 +22,8 @@
 #include "Common/SemanticError.h"
 
-LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
+namespace LinkageSpec {
+
+Spec linkageCheck( const string * spec ) {
+	assert( spec );
 	unique_ptr<const string> guard( spec );	// allocated by lexer
 	if ( *spec == "\"Cforall\"" ) {
@@ -35,55 +38,40 @@
 }
 
-string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
-	assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
-	static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
-		"intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", "cfa built-in", "c built-in",
-	};
-	return linkageKinds[linkage];
+Spec linkageUpdate( Spec old_spec, const string * cmd ) {
+	assert( cmd );
+	unique_ptr<const string> guard( cmd ); // allocated by lexer
+	if ( *cmd == "\"Cforall\"" ) {
+		old_spec.is_mangled = true;
+		return old_spec;
+	} else if ( *cmd == "\"C\"" ) {
+		old_spec.is_mangled = false;
+		return old_spec;
+	} else {
+		throw SemanticError( "Invalid linkage specifier " + *cmd );
+	} // if
 }
 
-bool LinkageSpec::isMangled( Spec spec ) {
-	assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
-	static bool decoratable[LinkageSpec::NoOfSpecs] = {
-		//	Intrinsic,	Cforall,	C,		AutoGen,	Compiler,
-			true,		true,		false,	true,		false,
-		//	Builtin,	BuiltinC,
-			true,		false,
-	};
-	return decoratable[spec];
+std::string linkageName( Spec linkage ) {
+    switch ( linkage ) {
+    case Intrinsic:
+        return "intrinsic";
+    case C:
+        return "C";
+    case Cforall:
+        return "Cforall";
+    case AutoGen:
+        return "autogenerated cfa";
+    case Compiler:
+        return "compiler built-in";
+    case BuiltinCFA:
+        return "cfa built-in";
+    case BuiltinC:
+        return "c built-in";
+    default:
+        return "<unnamed linkage spec>";
+    }
 }
 
-bool LinkageSpec::isGeneratable( Spec spec ) {
-	assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
-	static bool generatable[LinkageSpec::NoOfSpecs] = {
-		//	Intrinsic,	Cforall,	C,		AutoGen,	Compiler,
-			true,		true,		true,	true,		false,
-		//	Builtin,	BuiltinC,
-			true,		true,
-	};
-	return generatable[spec];
-}
-
-bool LinkageSpec::isOverridable( Spec spec ) {
-	assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
-	static bool overridable[LinkageSpec::NoOfSpecs] = {
-		//	Intrinsic,	Cforall,	C,		AutoGen,	Compiler,
-			true,		false,		false,	true,		false,
-		//	Builtin,	BuiltinC,
-			false,		false,
-	};
-	return overridable[spec];
-}
-
-bool LinkageSpec::isBuiltin( Spec spec ) {
-	assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
-	static bool builtin[LinkageSpec::NoOfSpecs] = {
-		//	Intrinsic,	Cforall,	C,		AutoGen,	Compiler,
-			true,		false,		false,	false,		true,
-		//	Builtin,	BuiltinC,
-			true,		true,
-	};
-	return builtin[spec];
-}
+} // LinkageSpec
 
 // Local Variables: //
Index: src/Parser/LinkageSpec.h
===================================================================
--- src/Parser/LinkageSpec.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Parser/LinkageSpec.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -5,11 +5,11 @@
 // file "LICENCE" distributed with Cforall.
 //
-// LinkageSpec.h -- 
+// LinkageSpec.h --
 //
 // Author           : Rodolfo G. Esteves
 // Created On       : Sat May 16 13:24:28 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Jun 28 11:50:00 2017
-// Update Count     : 12
+// Last Modified On : Fri Jul  7 11:03:00 2017
+// Update Count     : 13
 //
 
@@ -19,23 +19,61 @@
 #include <string>
 
-struct LinkageSpec {
-	enum Spec {
-		Intrinsic,										// C built-in defined in prelude
-		Cforall,										// ordinary
-		C,												// not overloadable, not mangled
-		AutoGen,										// built by translator (struct assignment)
-		Compiler,										// gcc internal
-		Builtin,										// mangled builtins
-		BuiltinC,										// non-mangled builtins
-		NoOfSpecs
+namespace LinkageSpec {
+	// All linkage specs are some combination of these flags:
+	enum {
+		Mangle = 1 << 0,
+		Generate = 1 << 1,
+		Overrideable = 1 << 2,
+		Builtin = 1 << 3,
+
+		NoOfSpecs = 1 << 4,
 	};
-  
-	static Spec linkageCheck( const std::string * );
-	static std::string linkageName( Spec );
-  
-	static bool isMangled( Spec );
-	static bool isGeneratable( Spec );
-	static bool isOverridable( Spec );
-	static bool isBuiltin( Spec );
+
+	union Spec {
+		unsigned int val;
+		struct {
+			bool is_mangled : 1;
+			bool is_generatable : 1;
+			bool is_overridable : 1;
+			bool is_builtin : 1;
+		};
+		constexpr Spec( unsigned int val ) : val( val ) {}
+		constexpr Spec( Spec const &other ) : val( other.val ) {}
+		// Operators may go here.
+		// Supports == and !=
+		constexpr operator unsigned int () const { return val; }
+	};
+
+
+	Spec linkageCheck( const std::string * );
+	// Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
+	Spec linkageUpdate( Spec old_spec, const std::string * cmd );
+	/* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
+	 * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
+	 */
+
+	std::string linkageName( Spec );
+
+	// To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
+	inline bool isMangled( Spec spec ) { return spec.is_mangled; }
+	inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
+	inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
+	inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
+
+	// Pre-defined flag combinations:
+	// C built-in defined in prelude
+	constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
+	// ordinary
+	constexpr Spec const Cforall = { Mangle | Generate };
+	// not overloadable, not mangled
+	constexpr Spec const C = { Generate };
+	// built by translator (struct assignment)
+	constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
+	// gcc internal
+	constexpr Spec const Compiler = { Builtin };
+	// mangled builtins
+	constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
+	// non-mangled builtins
+	constexpr Spec const BuiltinC = { Generate | Builtin };
 };
 
Index: src/Parser/StatementNode.cc
===================================================================
--- src/Parser/StatementNode.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Parser/StatementNode.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 14:59:41 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jun 28 21:08:37 2017
-// Update Count     : 330
+// Last Modified On : Tue Jul 11 21:23:15 2017
+// Update Count     : 331
 //
 
@@ -93,5 +93,5 @@
 	std::list< Statement * > branches;
 	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() >= 0 );						// size == 0 for switch (...) {}, i.e., no declaration or statements
+	// branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
 	return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
 }
Index: src/Parser/lex.ll
===================================================================
--- src/Parser/lex.ll	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Parser/lex.ll	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
  * Created On       : Sat Sep 22 08:58:10 2001
  * Last Modified By : Peter A. Buhr
- * Last Modified On : Wed Jun 28 21:03:45 2017
- * Update Count     : 529
+ * Last Modified On : Wed Jul 12 18:04:44 2017
+ * Update Count     : 535
  */
 
@@ -59,4 +59,6 @@
 }
 
+// Stop warning due to incorrectly generated flex code.
+#pragma GCC diagnostic ignored "-Wsign-compare"
 %}
 
@@ -272,4 +274,5 @@
 __volatile__	{ KEYWORD_RETURN(VOLATILE); }			// GCC
 while			{ KEYWORD_RETURN(WHILE); }
+with			{ KEYWORD_RETURN(WITH); }				// CFA
 zero_t			{ NUMERIC_RETURN(ZERO_T); }				// CFA
 
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/Parser/parser.yy	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Sat Sep  1 20:22:55 2001
-// Last Modified By : Andrew Beach
-// Last Modified On : Fri Jun 30 15:38:00 2017
-// Update Count     : 2415
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Jul 12 18:23:36 2017
+// Update Count     : 2426
 //
 
@@ -129,5 +129,5 @@
 %token ATTRIBUTE EXTENSION								// GCC
 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
-%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT	// CFA
+%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH	// CFA
 %token ASM												// C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
 %token ALIGNAS ALIGNOF GENERIC STATICASSERT				// C11
@@ -184,11 +184,12 @@
 // statements
 %type<sn> labeled_statement				compound_statement			expression_statement		selection_statement
-%type<sn> iteration_statement			jump_statement				exception_statement			asm_statement
+%type<sn> iteration_statement			jump_statement
+%type<sn> with_statement				exception_statement			asm_statement
 %type<sn> fall_through_opt				fall_through
 %type<sn> statement						statement_list
 %type<sn> block_item_list				block_item
-%type<sn> case_clause
+%type<sn> with_clause_opt
 %type<en> case_value
-%type<sn> case_value_list				case_label					case_label_list
+%type<sn> case_clause					case_value_list				case_label					case_label_list
 %type<sn> switch_clause_list_opt		switch_clause_list			choose_clause_list_opt		choose_clause_list
 %type<sn> /* handler_list */			handler_clause				finally_clause
@@ -729,4 +730,5 @@
 	| iteration_statement
 	| jump_statement
+	| with_statement
 	| exception_statement
 	| asm_statement
@@ -934,4 +936,9 @@
 	| THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
 		{ $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
+	;
+
+with_statement:
+	WITH identifier_list compound_statement
+		{ $$ = (StatementNode *)0; }					// FIX ME
 	;
 
@@ -2176,5 +2183,5 @@
 		{
 			linkageStack.push( linkage );				// handle nested extern "C"/"Cforall"
-			linkage = LinkageSpec::linkageCheck( $2 );
+			linkage = LinkageSpec::linkageUpdate( linkage, $2 );
 		}
 	  '{' external_definition_list_opt '}'
@@ -2212,62 +2219,69 @@
 	;
 
+with_clause_opt:
+	// empty
+		{ $$ = (StatementNode *)0; }					// FIX ME
+	| WITH identifier_list
+		{ $$ = (StatementNode *)0; }					// FIX ME
+	;
+
 function_definition:
-	cfa_function_declaration compound_statement			// CFA
+	cfa_function_declaration with_clause_opt compound_statement	// CFA
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $1->addFunctionBody( $2 );
-		}
-	| declaration_specifier function_declarator compound_statement
+			$$ = $1->addFunctionBody( $3 );
+		}
+	| declaration_specifier function_declarator with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addFunctionBody( $3 )->addType( $1 );
-		}
-	| type_qualifier_list function_declarator compound_statement
+			$$ = $2->addFunctionBody( $4 )->addType( $1 );
+		}
+	| type_qualifier_list function_declarator with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
-		}
-	| declaration_qualifier_list function_declarator compound_statement
+			$$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
+		}
+	| declaration_qualifier_list function_declarator with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
-		}
-	| declaration_qualifier_list type_qualifier_list function_declarator compound_statement
+			$$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
+		}
+	| declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 );
+			$$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );
 		}
 
 		// Old-style K&R function definition, OBSOLESCENT (see 4)
-	| declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement
+	| declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 );
-		}
-	| type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
+			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 );
+		}
+	| type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
+			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
 		}
 
 		// Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
-	| declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
+	| declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
-		}
-	| declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
+			$$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
+		}
+	| declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
 		{
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
-			$$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );
+			$$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 );
 		}
 	;
@@ -2332,5 +2346,5 @@
 	| TYPEGENname
 	| CONST
-		{ $$ = Token{ new string( "__const__" ) }; }
+		{ $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; }
 	;
 
Index: src/ResolvExpr/CurrentObject.cc
===================================================================
--- src/ResolvExpr/CurrentObject.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/ResolvExpr/CurrentObject.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -114,5 +114,5 @@
 		}
 
-		virtual void print( std::ostream & out, Indenter indent ) const {
+		virtual void print( std::ostream & out, __attribute__((unused)) Indenter indent ) const {
 			out << "SimpleIterator(" << type << ")";
 		}
Index: src/benchmark/CorCtxSwitch.c
===================================================================
--- src/benchmark/CorCtxSwitch.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/CorCtxSwitch.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -31,8 +31,4 @@
 
 	StartTime = Time();
-	// for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
-	// 	resume( this_coroutine() );
-	// 	// resume( &s );	
-	// }
 	resumer( &s, NoOfTimes );
 	EndTime = Time();
Index: src/benchmark/Makefile.am
===================================================================
--- src/benchmark/Makefile.am	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/Makefile.am	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -20,7 +20,7 @@
 CC = @CFA_BINDIR@/@CFA_NAME@
 
-noinst_PROGRAMS = bench ctxswitch-coroutine ctxswitch-thread
+noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT)
 
-bench :
+bench$(EXEEXT) :
 	@for ccflags in "-debug" "-nodebug"; do \
 		echo ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -lrt bench.c;\
@@ -30,5 +30,5 @@
 	rm -f ./a.out ;
 
-ctxswitch-coroutine:
+ctxswitch-coroutine$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 CorCtxSwitch.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -37,5 +37,5 @@
 	@rm -f ./a.out
 
-ctxswitch-thread:
+ctxswitch-thread$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 ThrdCtxSwitch.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -44,5 +44,5 @@
 	@rm -f ./a.out
 
-sched-int:
+sched-int$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -51,5 +51,5 @@
 	@rm -f ./a.out
 
-monitor:
+monitor$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -58,5 +58,5 @@
 	@rm -f ./a.out
 
-csv-data:
+csv-data$(EXEEXT):
 	@${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c
 	@./a.out
Index: src/benchmark/Makefile.in
===================================================================
--- src/benchmark/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -92,6 +92,4 @@
 build_triplet = @build@
 host_triplet = @host@
-noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) \
-	ctxswitch-thread$(EXEEXT)
 subdir = src/benchmark
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -108,4 +106,7 @@
 bench_OBJECTS = bench.$(OBJEXT)
 bench_LDADD = $(LDADD)
+csv_data_SOURCES = csv-data.c
+csv_data_OBJECTS = csv-data.$(OBJEXT)
+csv_data_LDADD = $(LDADD)
 ctxswitch_coroutine_SOURCES = ctxswitch-coroutine.c
 ctxswitch_coroutine_OBJECTS = ctxswitch-coroutine.$(OBJEXT)
@@ -114,4 +115,10 @@
 ctxswitch_thread_OBJECTS = ctxswitch-thread.$(OBJEXT)
 ctxswitch_thread_LDADD = $(LDADD)
+monitor_SOURCES = monitor.c
+monitor_OBJECTS = monitor.$(OBJEXT)
+monitor_LDADD = $(LDADD)
+sched_int_SOURCES = sched-int.c
+sched_int_OBJECTS = sched-int.$(OBJEXT)
+sched_int_LDADD = $(LDADD)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -142,6 +149,8 @@
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = bench.c ctxswitch-coroutine.c ctxswitch-thread.c
-DIST_SOURCES = bench.c ctxswitch-coroutine.c ctxswitch-thread.c
+SOURCES = bench.c csv-data.c ctxswitch-coroutine.c ctxswitch-thread.c \
+	monitor.c sched-int.c
+DIST_SOURCES = bench.c csv-data.c ctxswitch-coroutine.c \
+	ctxswitch-thread.c monitor.c sched-int.c
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -293,4 +302,5 @@
 top_srcdir = @top_srcdir@
 AM_CFLAGS = -g -Wall -Wno-unused-function -O2
+noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT)
 all: all-am
 
@@ -306,7 +316,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/benchmark/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/benchmark/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/benchmark/Makefile
+	  $(AUTOMAKE) --foreign src/benchmark/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -337,6 +347,9 @@
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv-data.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctxswitch-coroutine.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctxswitch-thread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched-int.Po@am__quote@
 
 .c.o:
@@ -559,5 +572,5 @@
 
 
-bench :
+bench$(EXEEXT) :
 	@for ccflags in "-debug" "-nodebug"; do \
 		echo ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -lrt bench.c;\
@@ -567,5 +580,5 @@
 	rm -f ./a.out ;
 
-ctxswitch-coroutine:
+ctxswitch-coroutine$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 CorCtxSwitch.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -574,5 +587,5 @@
 	@rm -f ./a.out
 
-ctxswitch-thread:
+ctxswitch-thread$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 ThrdCtxSwitch.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -581,5 +594,5 @@
 	@rm -f ./a.out
 
-sched-int:
+sched-int$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -588,5 +601,5 @@
 	@rm -f ./a.out
 
-monitor:
+monitor$(EXEEXT):
 	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c
 	@for number in 1 2 3 4 5 6 7 8 9 10; do \
@@ -595,5 +608,5 @@
 	@rm -f ./a.out
 
-csv-data:
+csv-data$(EXEEXT):
 	@${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c
 	@./a.out
Index: src/benchmark/bench.h
===================================================================
--- src/benchmark/bench.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/bench.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -26,2 +26,6 @@
 #define N 10000000
 #endif
+
+unsigned int default_preemption() {
+	return 0;
+}
Index: src/benchmark/create_pthrd.c
===================================================================
--- src/benchmark/create_pthrd.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/create_pthrd.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,13 +17,10 @@
 
 	for (size_t i = 0; i < n; i++) {
-		pthread_attr_t attr;
-		if (pthread_attr_init(&attr) < 0) {
+		pthread_t thread;
+		if (pthread_create(&thread, NULL, foo, NULL) < 0) {
 			return 1;
 		}
-		if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) < 0) {
-			return 1;
-		}
-		pthread_t thread;
-		if (pthread_create(&thread, &attr, foo, NULL) < 0) {
+
+		if (pthread_join( thread, NULL) < 0) {
 			return 1;
 		}
Index: src/benchmark/csv-data.c
===================================================================
--- src/benchmark/csv-data.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/benchmark/csv-data.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -25,8 +25,4 @@
 }
 
-#ifndef N
-#define N 100000000
-#endif
-
 //-----------------------------------------------------------------------------
 // coroutine context switch
@@ -38,8 +34,4 @@
 
 	StartTime = Time();
-	// for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
-	// 	resume( this_coroutine() );
-	// 	// resume( &s );
-	// }
 	resumer( &s, NoOfTimes );
 	EndTime = Time();
@@ -104,5 +96,5 @@
 mon_t mon1;
 
-condition cond1a; 
+condition cond1a;
 condition cond1b;
 
@@ -152,5 +144,5 @@
 mon_t mon2;
 
-condition cond2a; 
+condition cond2a;
 condition cond2b;
 
Index: src/benchmark/interrupt_linux.c
===================================================================
--- src/benchmark/interrupt_linux.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
+++ src/benchmark/interrupt_linux.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -0,0 +1,35 @@
+#include <pthread.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#define __CFA_SIGCXT__ ucontext_t *
+#define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt
+
+void sigHandler( __CFA_SIGPARMS__ ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, SIGUSR1 );
+
+	if ( sigprocmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
+		abort();
+	} // if
+}
+
+int main() {
+
+	struct sigaction act;
+
+	act.sa_sigaction = (void (*)(int, siginfo_t *, void *))sigHandler;
+	sigemptyset( &act.sa_mask );
+	sigaddset( &act.sa_mask, SIGUSR1 );
+
+	act.sa_flags = SA_SIGINFO;
+
+	if ( sigaction( SIGUSR1, &act, NULL ) == -1 ) {
+		abort();
+	} // if
+
+	for( int i = 0; i < 50000000ul; i++ ) {
+		pthread_kill( pthread_self(), SIGUSR1 );
+	}
+}
Index: src/driver/Makefile.in
===================================================================
--- src/driver/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/driver/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -315,7 +315,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/driver/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/driver/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/driver/Makefile
+	  $(AUTOMAKE) --foreign src/driver/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/examples/Makefile.in
===================================================================
--- src/examples/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/examples/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -319,7 +319,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/examples/Makefile
+	  $(AUTOMAKE) --foreign src/examples/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/include/assert.h
===================================================================
--- src/include/assert.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/include/assert.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -15,4 +15,6 @@
 
 #pragma once
+// Pragmas for header cleanup tool
+// IWYU pragma: private, include <cassert>
 
 #include_next <assert.h>
Index: src/libcfa/Makefile.am
===================================================================
--- src/libcfa/Makefile.am	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/Makefile.am	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -17,4 +17,5 @@
 # create object files in directory with source files
 AUTOMAKE_OPTIONS = subdir-objects
+ARFLAGS = cr
 
 libdir = ${CFA_LIBDIR}
Index: src/libcfa/Makefile.in
===================================================================
--- src/libcfa/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -142,5 +142,4 @@
 LIBRARIES = $(lib_LIBRARIES)
 AR = ar
-ARFLAGS = cru
 AM_V_AR = $(am__v_AR_@AM_V@)
 am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
@@ -409,4 +408,5 @@
 # create object files in directory with source files
 AUTOMAKE_OPTIONS = subdir-objects
+ARFLAGS = cr
 lib_LIBRARIES = $(am__append_1) $(am__append_2)
 EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -I${abs_top_srcdir}/src/libcfa/libhdr -imacros libcfa-prelude.c @CFA_FLAGS@
@@ -439,7 +439,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libcfa/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/libcfa/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/libcfa/Makefile
+	  $(AUTOMAKE) --foreign src/libcfa/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/libcfa/concurrency/CtxSwitch-i386.S
===================================================================
--- src/libcfa/concurrency/CtxSwitch-i386.S	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/CtxSwitch-i386.S	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -98,13 +98,4 @@
 	ret
 
-.text
-	.align 2
-.globl	CtxGet
-CtxGet:
-	movl %esp,SP_OFFSET(%eax)
-	movl %ebp,FP_OFFSET(%eax)
-
-	ret
-
 // Local Variables: //
 // compile-command: "make install" //
Index: src/libcfa/concurrency/CtxSwitch-x86_64.S
===================================================================
--- src/libcfa/concurrency/CtxSwitch-x86_64.S	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/CtxSwitch-x86_64.S	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -1,3 +1,3 @@
-//                               -*- Mode: Asm -*- 
+//                               -*- Mode: Asm -*-
 //
 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
@@ -18,13 +18,13 @@
 // Free Software  Foundation; either  version 2.1 of  the License, or  (at your
 // option) any later version.
-// 
+//
 // This library is distributed in the  hope that it will be useful, but WITHOUT
 // ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 // for more details.
-// 
+//
 // You should  have received a  copy of the  GNU Lesser General  Public License
 // along  with this library.
-// 
+//
 
 // This context switch routine depends on the fact that the stack of a new
@@ -93,15 +93,6 @@
 .globl	CtxInvokeStub
 CtxInvokeStub:
-	movq %rbx, %rdi 
+	movq %rbx, %rdi
 	jmp *%r12
-
-.text
-	.align 2
-.globl	CtxGet
-CtxGet:
-	movq %rsp,SP_OFFSET(%rdi)
-	movq %rbp,FP_OFFSET(%rdi)
-
-	ret
 
 // Local Variables: //
Index: src/libcfa/concurrency/alarm.c
===================================================================
--- src/libcfa/concurrency/alarm.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/alarm.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -16,7 +16,13 @@
 
 extern "C" {
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
 #include <time.h>
+#include <unistd.h>
 #include <sys/time.h>
 }
+
+#include "libhdr.h"
 
 #include "alarm.h"
@@ -31,8 +37,11 @@
 	timespec curr;
 	clock_gettime( CLOCK_REALTIME, &curr );
-	return ((__cfa_time_t)curr.tv_sec * TIMEGRAN) + curr.tv_nsec;
+	__cfa_time_t curr_time = ((__cfa_time_t)curr.tv_sec * TIMEGRAN) + curr.tv_nsec;
+	// LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : current time is %lu\n", curr_time );
+	return curr_time;
 }
 
 void __kernel_set_timer( __cfa_time_t alarm ) {
+	LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : set timer to %lu\n", (__cfa_time_t)alarm );
 	itimerval val;
 	val.it_value.tv_sec = alarm / TIMEGRAN;			// seconds
@@ -71,6 +80,15 @@
 }
 
+LIB_DEBUG_DO( bool validate( alarm_list_t * this ) {
+	alarm_node_t ** it = &this->head;
+	while( (*it) ) {
+		it = &(*it)->next;
+	}
+
+	return it == this->tail;
+})
+
 static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
-	assert( !n->next );
+	verify( !n->next );
 	if( p == this->tail ) {
 		this->tail = &n->next;
@@ -80,4 +98,6 @@
 	}
 	*p = n;
+
+	verify( validate( this ) );
 }
 
@@ -89,4 +109,6 @@
 
 	insert_at( this, n, it );
+
+	verify( validate( this ) );
 }
 
@@ -100,4 +122,5 @@
 		head->next = NULL;
 	}
+	verify( validate( this ) );
 	return head;
 }
@@ -105,43 +128,60 @@
 static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
 	verify( it );
-	verify( (*it)->next == n );
+	verify( (*it) == n );
 
-	(*it)->next = n->next;
+	(*it) = n->next;
 	if( !n-> next ) {
 		this->tail = it;
 	}
 	n->next = NULL;
+
+	verify( validate( this ) );
 }
 
 static inline void remove( alarm_list_t * this, alarm_node_t * n ) {
 	alarm_node_t ** it = &this->head;
-	while( (*it) && (*it)->next != n ) {
+	while( (*it) && (*it) != n ) {
 		it = &(*it)->next;
 	}
 
+	verify( validate( this ) );
+
 	if( *it ) { remove_at( this, n, it ); }
+
+	verify( validate( this ) );
 }
 
 void register_self( alarm_node_t * this ) {
 	disable_interrupts();
-	assert( !systemProcessor->pending_alarm );
-	lock( &systemProcessor->alarm_lock );
+	verify( !systemProcessor->pending_alarm );
+	lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
 	{
+		verify( validate( &systemProcessor->alarms ) );
+		bool first = !systemProcessor->alarms.head;
+
 		insert( &systemProcessor->alarms, this );
 		if( systemProcessor->pending_alarm ) {
 			tick_preemption();
 		}
+		if( first ) {
+			__kernel_set_timer( systemProcessor->alarms.head->alarm - __kernel_get_time() );
+		}
 	}
 	unlock( &systemProcessor->alarm_lock );
 	this->set = true;
-	enable_interrupts();
+	enable_interrupts( DEBUG_CTX );
 }
 
 void unregister_self( alarm_node_t * this ) {
+	// LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : unregister %p start\n", this );
 	disable_interrupts();
-	lock( &systemProcessor->alarm_lock );
-	remove( &systemProcessor->alarms, this );
+	lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
+	{
+		verify( validate( &systemProcessor->alarms ) );
+		remove( &systemProcessor->alarms, this );
+	}
 	unlock( &systemProcessor->alarm_lock );
-	disable_interrupts();
+	enable_interrupts( DEBUG_CTX );
 	this->set = false;
+	// LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Kernel : unregister %p end\n", this );
 }
Index: src/libcfa/concurrency/coroutine
===================================================================
--- src/libcfa/concurrency/coroutine	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/coroutine	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -63,5 +63,5 @@
 
 // Get current coroutine
-coroutine_desc * this_coroutine(void);
+extern volatile thread_local coroutine_desc * this_coroutine;
 
 // Private wrappers for context switch and stack creation
@@ -71,5 +71,5 @@
 // Suspend implementation inlined for performance
 static inline void suspend() {
-	coroutine_desc * src = this_coroutine();		// optimization
+	coroutine_desc * src = this_coroutine;		// optimization
 
 	assertf( src->last != 0,
@@ -88,5 +88,5 @@
 forall(dtype T | is_coroutine(T))
 static inline void resume(T * cor) {
-	coroutine_desc * src = this_coroutine();		// optimization
+	coroutine_desc * src = this_coroutine;		// optimization
 	coroutine_desc * dst = get_coroutine(cor);
 
@@ -112,5 +112,5 @@
 
 static inline void resume(coroutine_desc * dst) {
-	coroutine_desc * src = this_coroutine();		// optimization
+	coroutine_desc * src = this_coroutine;		// optimization
 
 	// not resuming self ?
Index: src/libcfa/concurrency/coroutine.c
===================================================================
--- src/libcfa/concurrency/coroutine.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/coroutine.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -32,5 +32,5 @@
 #include "invoke.h"
 
-extern thread_local processor * this_processor;
+extern volatile thread_local processor * this_processor;
 
 //-----------------------------------------------------------------------------
@@ -44,5 +44,5 @@
 // Coroutine ctors and dtors
 void ?{}(coStack_t* this) {
-	this->size		= 10240;	// size of stack
+	this->size		= 65000;	// size of stack
 	this->storage	= NULL;	// pointer to stack
 	this->limit		= NULL;	// stack grows towards stack limit
@@ -50,5 +50,5 @@
 	this->context	= NULL;	// address of cfa_context_t
 	this->top		= NULL;	// address of top of storage
-	this->userStack	= false;	
+	this->userStack	= false;
 }
 
@@ -106,12 +106,13 @@
 
 	// set state of current coroutine to inactive
-	src->state = Inactive;
+	src->state = src->state == Halted ? Halted : Inactive;
 
 	// set new coroutine that task is executing
-	this_processor->current_coroutine = dst;
+	this_coroutine = dst;
 
 	// context switch to specified coroutine
+	assert( src->stack.context );
 	CtxSwitch( src->stack.context, dst->stack.context );
-	// when CtxSwitch returns we are back in the src coroutine		
+	// when CtxSwitch returns we are back in the src coroutine
 
 	// set state of new coroutine to active
@@ -131,5 +132,5 @@
 		this->size = libCeiling( storageSize, 16 );
 		// use malloc/memalign because "new" raises an exception for out-of-memory
-		
+
 		// assume malloc has 8 byte alignment so add 8 to allow rounding up to 16 byte alignment
 		LIB_DEBUG_DO( this->storage = memalign( pageSize, cxtSize + this->size + pageSize ) );
Index: src/libcfa/concurrency/invoke.c
===================================================================
--- src/libcfa/concurrency/invoke.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/invoke.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -29,9 +29,11 @@
 
 extern void __suspend_internal(void);
-extern void __leave_monitor_desc( struct monitor_desc * this );
+extern void __leave_thread_monitor( struct thread_desc * this );
+extern void disable_interrupts();
+extern void enable_interrupts( DEBUG_CTX_PARAM );
 
 void CtxInvokeCoroutine(
-      void (*main)(void *), 
-      struct coroutine_desc *(*get_coroutine)(void *), 
+      void (*main)(void *),
+      struct coroutine_desc *(*get_coroutine)(void *),
       void *this
 ) {
@@ -56,23 +58,30 @@
 
 void CtxInvokeThread(
-      void (*dtor)(void *), 
-      void (*main)(void *), 
-      struct thread_desc *(*get_thread)(void *), 
+      void (*dtor)(void *),
+      void (*main)(void *),
+      struct thread_desc *(*get_thread)(void *),
       void *this
 ) {
+      // First suspend, once the thread arrives here,
+      // the function pointer to main can be invalidated without risk
       __suspend_internal();
 
+      // Fetch the thread handle from the user defined thread structure
       struct thread_desc* thrd = get_thread( this );
-      struct coroutine_desc* cor = &thrd->cor;
-      struct monitor_desc* mon = &thrd->mon;
-      cor->state = Active;
 
-      // LIB_DEBUG_PRINTF("Invoke Thread : invoking main %p (args %p)\n", main, this);
+      // Officially start the thread by enabling preemption
+      enable_interrupts( DEBUG_CTX );
+
+      // Call the main of the thread
       main( this );
 
-      __leave_monitor_desc( mon );
-
+      // To exit a thread we must :
+      // 1 - Mark it as halted
+      // 2 - Leave its monitor
+      // 3 - Disable the interupts
+      // 4 - Final suspend
+      // The order of these 4 operations is very important
       //Final suspend, should never return
-      __suspend_internal();
+      __leave_thread_monitor( thrd );
       abortf("Resumed dead thread");
 }
@@ -80,7 +89,7 @@
 
 void CtxStart(
-      void (*main)(void *), 
-      struct coroutine_desc *(*get_coroutine)(void *), 
-      void *this, 
+      void (*main)(void *),
+      struct coroutine_desc *(*get_coroutine)(void *),
+      void *this,
       void (*invoke)(void *)
 ) {
@@ -108,5 +117,5 @@
 	((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 
+      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F;  //Vol. 1 8-7
 
 #elif defined( __x86_64__ )
@@ -128,5 +137,5 @@
       ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = 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 
+      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F;  //Vol. 1 8-7
 #else
       #error Only __i386__ and __x86_64__ is supported for threads in cfa
Index: src/libcfa/concurrency/invoke.h
===================================================================
--- src/libcfa/concurrency/invoke.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/invoke.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -31,4 +31,8 @@
       struct spinlock {
             volatile int lock;
+            #ifdef __CFA_DEBUG__
+                  const char * prev_name;
+                  void* prev_thrd;
+            #endif
       };
 
@@ -83,5 +87,4 @@
             struct __thread_queue_t entry_queue;      // queue of threads that are blocked waiting for the monitor
             struct __condition_stack_t signal_stack;  // stack of conditions to run next once we exit the monitor
-            struct monitor_desc * stack_owner;        // if bulk acquiring was used we need to synchronize signals with an other monitor
             unsigned int recursion;                   // monitor routines can be called recursively, we need to keep track of that
       };
@@ -99,5 +102,5 @@
 #ifndef _INVOKE_PRIVATE_H_
 #define _INVOKE_PRIVATE_H_
-      
+
       struct machine_context_t {
             void *SP;
@@ -109,5 +112,16 @@
       extern void CtxInvokeStub( void );
       void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
-      void CtxGet( void * this ) asm ("CtxGet");
+
+      #if   defined( __x86_64__ )
+      #define CtxGet( ctx ) __asm__ ( \
+                  "movq %%rsp,%0\n"   \
+                  "movq %%rbp,%1\n"   \
+            : "=rm" (ctx.SP), "=rm" (ctx.FP) )
+      #elif defined( __i386__ )
+      #define CtxGet( ctx ) __asm__ ( \
+                  "movl %%esp,%0\n"   \
+                  "movl %%ebp,%1\n"   \
+            : "=rm" (ctx.SP), "=rm" (ctx.FP) )
+      #endif
 
 #endif //_INVOKE_PRIVATE_H_
Index: src/libcfa/concurrency/kernel
===================================================================
--- src/libcfa/concurrency/kernel	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/kernel	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -28,19 +28,20 @@
 //-----------------------------------------------------------------------------
 // Locks
-bool try_lock( spinlock * );
-void lock( spinlock * );
-void unlock( spinlock * );
+bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );
+void lock      ( spinlock * DEBUG_CTX_PARAM2 );
+void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
+void unlock    ( spinlock * );
 
-struct signal_once {
-	volatile bool cond;
-	struct spinlock lock;
-	struct __thread_queue_t blocked;
+struct semaphore {
+	spinlock lock;
+	int count;
+	__thread_queue_t waiting;
 };
 
-void ?{}(signal_once * this);
-void ^?{}(signal_once * this);
+void  ?{}(semaphore * this, int count = 1);
+void ^?{}(semaphore * this);
+void P(semaphore * this);
+void V(semaphore * this);
 
-void wait( signal_once * );
-void signal( signal_once * );
 
 //-----------------------------------------------------------------------------
@@ -68,5 +69,5 @@
 	unsigned short thrd_count;
 };
-static inline void ?{}(FinishAction * this) { 
+static inline void ?{}(FinishAction * this) {
 	this->action_code = No_Action;
 	this->thrd = NULL;
@@ -78,9 +79,7 @@
 	struct processorCtx_t * runner;
 	cluster * cltr;
-	coroutine_desc * current_coroutine;
-	thread_desc * current_thread;
 	pthread_t kernel_thread;
-	
-	signal_once terminated;
+
+	semaphore terminated;
 	volatile bool is_terminated;
 
@@ -90,7 +89,7 @@
 	unsigned int preemption;
 
-	unsigned short disable_preempt_count;
+	bool pending_preemption;
 
-	bool pending_preemption;
+	char * last_enable;
 };
 
Index: src/libcfa/concurrency/kernel.c
===================================================================
--- src/libcfa/concurrency/kernel.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/kernel.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -15,12 +15,5 @@
 //
 
-#include "startup.h"
-
-//Start and stop routine for the kernel, declared first to make sure they run first
-void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
-void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
-
-//Header
-#include "kernel_private.h"
+#include "libhdr.h"
 
 //C Includes
@@ -35,6 +28,7 @@
 
 //CFA Includes
-#include "libhdr.h"
+#include "kernel_private.h"
 #include "preemption.h"
+#include "startup.h"
 
 //Private includes
@@ -42,7 +36,11 @@
 #include "invoke.h"
 
+//Start and stop routine for the kernel, declared first to make sure they run first
+void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
+void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
+
 //-----------------------------------------------------------------------------
 // Kernel storage
-#define KERNEL_STORAGE(T,X) static char X##_storage[sizeof(T)]
+#define KERNEL_STORAGE(T,X) static char X##Storage[sizeof(T)]
 
 KERNEL_STORAGE(processorCtx_t, systemProcessorCtx);
@@ -50,5 +48,5 @@
 KERNEL_STORAGE(system_proc_t, systemProcessor);
 KERNEL_STORAGE(thread_desc, mainThread);
-KERNEL_STORAGE(machine_context_t, mainThread_context);
+KERNEL_STORAGE(machine_context_t, mainThreadCtx);
 
 cluster * systemCluster;
@@ -59,18 +57,14 @@
 // Global state
 
-thread_local processor * this_processor;
-
-coroutine_desc * this_coroutine(void) {
-	return this_processor->current_coroutine;
-}
-
-thread_desc * this_thread(void) {
-	return this_processor->current_thread;
-}
+volatile thread_local processor * this_processor;
+volatile thread_local coroutine_desc * this_coroutine;
+volatile thread_local thread_desc * this_thread;
+volatile thread_local bool preemption_in_progress = 0;
+volatile thread_local unsigned short disable_preempt_count = 1;
 
 //-----------------------------------------------------------------------------
 // Main thread construction
 struct current_stack_info_t {
-	machine_context_t ctx;	
+	machine_context_t ctx;
 	unsigned int size;		// size of stack
 	void *base;				// base of stack
@@ -82,5 +76,5 @@
 
 void ?{}( current_stack_info_t * this ) {
-	CtxGet( &this->ctx );
+	CtxGet( this->ctx );
 	this->base = this->ctx.FP;
 	this->storage = this->ctx.SP;
@@ -91,5 +85,5 @@
 
 	this->limit = (void *)(((intptr_t)this->base) - this->size);
-	this->context = &mainThread_context_storage;
+	this->context = &mainThreadCtxStorage;
 	this->top = this->base;
 }
@@ -106,5 +100,5 @@
 
 void ?{}( coroutine_desc * this, current_stack_info_t * info) {
-	(&this->stack){ info };	
+	(&this->stack){ info };
 	this->name = "Main Thread";
 	this->errno_ = 0;
@@ -136,11 +130,8 @@
 void ?{}(processor * this, cluster * cltr) {
 	this->cltr = cltr;
-	this->current_coroutine = NULL;
-	this->current_thread = NULL;
-	(&this->terminated){};
+	(&this->terminated){ 0 };
 	this->is_terminated = false;
 	this->preemption_alarm = NULL;
 	this->preemption = default_preemption();
-	this->disable_preempt_count = 1;		//Start with interrupts disabled
 	this->pending_preemption = false;
 
@@ -150,15 +141,17 @@
 void ?{}(processor * this, cluster * cltr, processorCtx_t * runner) {
 	this->cltr = cltr;
-	this->current_coroutine = NULL;
-	this->current_thread = NULL;
-	(&this->terminated){};
+	(&this->terminated){ 0 };
 	this->is_terminated = false;
-	this->disable_preempt_count = 0;
+	this->preemption_alarm = NULL;
+	this->preemption = default_preemption();
 	this->pending_preemption = false;
+	this->kernel_thread = pthread_self();
 
 	this->runner = runner;
-	LIB_DEBUG_PRINT_SAFE("Kernel : constructing processor context %p\n", runner);
+	LIB_DEBUG_PRINT_SAFE("Kernel : constructing system processor context %p\n", runner);
 	runner{ this };
 }
+
+LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
 
 void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) {
@@ -168,4 +161,6 @@
 
 	(&this->proc){ cltr, runner };
+
+	verify( validate( &this->alarms ) );
 }
 
@@ -174,5 +169,6 @@
 		LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this);
 		this->is_terminated = true;
-		wait( &this->terminated );
+		P( &this->terminated );
+		pthread_join( this->kernel_thread, NULL );
 	}
 }
@@ -184,5 +180,5 @@
 
 void ^?{}(cluster * this) {
-	
+
 }
 
@@ -203,5 +199,5 @@
 
 		thread_desc * readyThread = NULL;
-		for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ ) 
+		for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
 		{
 			readyThread = nextThread( this->cltr );
@@ -209,5 +205,9 @@
 			if(readyThread)
 			{
+				verify( disable_preempt_count > 0 );
+
 				runThread(this, readyThread);
+
+				verify( disable_preempt_count > 0 );
 
 				//Some actions need to be taken from the kernel
@@ -225,19 +225,20 @@
 	}
 
-	signal( &this->terminated );
+	V( &this->terminated );
+
 	LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
 }
 
-// runThread runs a thread by context switching 
-// from the processor coroutine to the target thread 
+// runThread runs a thread by context switching
+// from the processor coroutine to the target thread
 void runThread(processor * this, thread_desc * dst) {
 	coroutine_desc * proc_cor = get_coroutine(this->runner);
 	coroutine_desc * thrd_cor = get_coroutine(dst);
-	
+
 	//Reset the terminating actions here
 	this->finish.action_code = No_Action;
 
 	//Update global state
-	this->current_thread = dst;
+	this_thread = dst;
 
 	// Context Switch to the thread
@@ -246,5 +247,5 @@
 }
 
-// Once a thread has finished running, some of 
+// Once a thread has finished running, some of
 // its final actions must be executed from the kernel
 void finishRunning(processor * this) {
@@ -256,5 +257,5 @@
 	}
 	else if( this->finish.action_code == Release_Schedule ) {
-		unlock( this->finish.lock );		
+		unlock( this->finish.lock );
 		ScheduleThread( this->finish.thrd );
 	}
@@ -289,7 +290,10 @@
 	processor * proc = (processor *) arg;
 	this_processor = proc;
+	this_coroutine = NULL;
+	this_thread = NULL;
+	disable_preempt_count = 1;
 	// SKULLDUGGERY: We want to create a context for the processor coroutine
 	// which is needed for the 2-step context switch. However, there is no reason
-	// to waste the perfectly valid stack create by pthread. 
+	// to waste the perfectly valid stack create by pthread.
 	current_stack_info_t info;
 	machine_context_t ctx;
@@ -300,13 +304,13 @@
 
 	//Set global state
-	proc->current_coroutine = &proc->runner->__cor;
-	proc->current_thread = NULL;
+	this_coroutine = &proc->runner->__cor;
+	this_thread = NULL;
 
 	//We now have a proper context from which to schedule threads
 	LIB_DEBUG_PRINT_SAFE("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
 
-	// SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't 
-	// resume it to start it like it normally would, it will just context switch 
-	// back to here. Instead directly call the main since we already are on the 
+	// SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
+	// resume it to start it like it normally would, it will just context switch
+	// back to here. Instead directly call the main since we already are on the
 	// appropriate stack.
 	proc_cor_storage.__cor.state = Active;
@@ -315,5 +319,5 @@
 
 	// Main routine of the core returned, the core is now fully terminated
-	LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner);	
+	LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner);
 
 	return NULL;
@@ -322,8 +326,8 @@
 void start(processor * this) {
 	LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
-	
+
 	pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
 
-	LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);	
+	LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
 }
 
@@ -331,51 +335,89 @@
 // Scheduler routines
 void ScheduleThread( thread_desc * thrd ) {
-	if( !thrd ) return;
+	// if( !thrd ) return;
+	assert( thrd );
+	assert( thrd->cor.state != Halted );
+
+	verify( disable_preempt_count > 0 );
 
 	verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
-	
-	lock( &systemProcessor->proc.cltr->lock );
+
+	lock( &systemProcessor->proc.cltr->lock DEBUG_CTX2 );
 	append( &systemProcessor->proc.cltr->ready_queue, thrd );
 	unlock( &systemProcessor->proc.cltr->lock );
+
+	verify( disable_preempt_count > 0 );
 }
 
 thread_desc * nextThread(cluster * this) {
-	lock( &this->lock );
+	verify( disable_preempt_count > 0 );
+	lock( &this->lock DEBUG_CTX2 );
 	thread_desc * head = pop_head( &this->ready_queue );
 	unlock( &this->lock );
+	verify( disable_preempt_count > 0 );
 	return head;
 }
 
-void ScheduleInternal() {
+void BlockInternal() {
+	disable_interrupts();
+	verify( disable_preempt_count > 0 );
 	suspend();
-}
-
-void ScheduleInternal( spinlock * lock ) {
+	verify( disable_preempt_count > 0 );
+	enable_interrupts( DEBUG_CTX );
+}
+
+void BlockInternal( spinlock * lock ) {
+	disable_interrupts();
 	this_processor->finish.action_code = Release;
 	this_processor->finish.lock = lock;
+
+	verify( disable_preempt_count > 0 );
 	suspend();
-}
-
-void ScheduleInternal( thread_desc * thrd ) {
+	verify( disable_preempt_count > 0 );
+
+	enable_interrupts( DEBUG_CTX );
+}
+
+void BlockInternal( thread_desc * thrd ) {
+	disable_interrupts();
+	assert( thrd->cor.state != Halted );
 	this_processor->finish.action_code = Schedule;
 	this_processor->finish.thrd = thrd;
+
+	verify( disable_preempt_count > 0 );
 	suspend();
-}
-
-void ScheduleInternal( spinlock * lock, thread_desc * thrd ) {
+	verify( disable_preempt_count > 0 );
+
+	enable_interrupts( DEBUG_CTX );
+}
+
+void BlockInternal( spinlock * lock, thread_desc * thrd ) {
+	disable_interrupts();
 	this_processor->finish.action_code = Release_Schedule;
 	this_processor->finish.lock = lock;
 	this_processor->finish.thrd = thrd;
+
+	verify( disable_preempt_count > 0 );
 	suspend();
-}
-
-void ScheduleInternal(spinlock ** locks, unsigned short count) {
+	verify( disable_preempt_count > 0 );
+
+	enable_interrupts( DEBUG_CTX );
+}
+
+void BlockInternal(spinlock ** locks, unsigned short count) {
+	disable_interrupts();
 	this_processor->finish.action_code = Release_Multi;
 	this_processor->finish.locks = locks;
 	this_processor->finish.lock_count = count;
+
+	verify( disable_preempt_count > 0 );
 	suspend();
-}
-
-void ScheduleInternal(spinlock ** locks, unsigned short lock_count, thread_desc ** thrds, unsigned short thrd_count) {
+	verify( disable_preempt_count > 0 );
+
+	enable_interrupts( DEBUG_CTX );
+}
+
+void BlockInternal(spinlock ** locks, unsigned short lock_count, thread_desc ** thrds, unsigned short thrd_count) {
+	disable_interrupts();
 	this_processor->finish.action_code = Release_Multi_Schedule;
 	this_processor->finish.locks = locks;
@@ -383,4 +425,18 @@
 	this_processor->finish.thrds = thrds;
 	this_processor->finish.thrd_count = thrd_count;
+
+	verify( disable_preempt_count > 0 );
+	suspend();
+	verify( disable_preempt_count > 0 );
+
+	enable_interrupts( DEBUG_CTX );
+}
+
+void LeaveThread(spinlock * lock, thread_desc * thrd) {
+	verify( disable_preempt_count > 0 );
+	this_processor->finish.action_code = thrd ? Release_Schedule : Release;
+	this_processor->finish.lock = lock;
+	this_processor->finish.thrd = thrd;
+
 	suspend();
 }
@@ -392,10 +448,10 @@
 // Kernel boot procedures
 void kernel_startup(void) {
-	LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");	
+	LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");
 
 	// Start by initializing the main thread
-	// SKULLDUGGERY: the mainThread steals the process main thread 
+	// SKULLDUGGERY: the mainThread steals the process main thread
 	// which will then be scheduled by the systemProcessor normally
-	mainThread = (thread_desc *)&mainThread_storage;
+	mainThread = (thread_desc *)&mainThreadStorage;
 	current_stack_info_t info;
 	mainThread{ &info };
@@ -403,30 +459,31 @@
 	LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n");
 
+	// Initialize the system cluster
+	systemCluster = (cluster *)&systemClusterStorage;
+	systemCluster{};
+
+	LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n");
+
+	// Initialize the system processor and the system processor ctx
+	// (the coroutine that contains the processing control flow)
+	systemProcessor = (system_proc_t *)&systemProcessorStorage;
+	systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage };
+
+	// Add the main thread to the ready queue
+	// once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
+	ScheduleThread(mainThread);
+
+	//initialize the global state variables
+	this_processor = &systemProcessor->proc;
+	this_thread = mainThread;
+	this_coroutine = &mainThread->cor;
+	disable_preempt_count = 1;
+
 	// Enable preemption
 	kernel_start_preemption();
 
-	// Initialize the system cluster
-	systemCluster = (cluster *)&systemCluster_storage;
-	systemCluster{};
-
-	LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n");
-
-	// Initialize the system processor and the system processor ctx
-	// (the coroutine that contains the processing control flow)
-	systemProcessor = (system_proc_t *)&systemProcessor_storage;
-	systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage };
-
-	// Add the main thread to the ready queue 
-	// once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
-	ScheduleThread(mainThread);
-
-	//initialize the global state variables
-	this_processor = &systemProcessor->proc;
-	this_processor->current_thread = mainThread;
-	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
 	// context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
-	// mainThread is on the ready queue when this call is made. 
+	// mainThread is on the ready queue when this call is made.
 	resume( systemProcessor->proc.runner );
 
@@ -435,8 +492,12 @@
 	// THE SYSTEM IS NOW COMPLETELY RUNNING
 	LIB_DEBUG_PRINT_SAFE("Kernel : Started\n--------------------------------------------------\n\n");
+
+	enable_interrupts( DEBUG_CTX );
 }
 
 void kernel_shutdown(void) {
 	LIB_DEBUG_PRINT_SAFE("\n--------------------------------------------------\nKernel : Shutting down\n");
+
+	disable_interrupts();
 
 	// SKULLDUGGERY: Notify the systemProcessor it needs to terminates.
@@ -448,4 +509,7 @@
 	// THE SYSTEM IS NOW COMPLETELY STOPPED
 
+	// Disable preemption
+	kernel_stop_preemption();
+
 	// Destroy the system processor and its context in reverse order of construction
 	// These were manually constructed so we need manually destroy them
@@ -457,5 +521,5 @@
 	^(mainThread){};
 
-	LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");	
+	LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");
 }
 
@@ -467,5 +531,5 @@
 	// abort cannot be recursively entered by the same or different processors because all signal handlers return when
 	// the globalAbort flag is true.
-	lock( &kernel_abort_lock );
+	lock( &kernel_abort_lock DEBUG_CTX2 );
 
 	// first task to abort ?
@@ -473,8 +537,8 @@
 		kernel_abort_called = true;
 		unlock( &kernel_abort_lock );
-	} 
+	}
 	else {
 		unlock( &kernel_abort_lock );
-		
+
 		sigset_t mask;
 		sigemptyset( &mask );
@@ -482,8 +546,8 @@
 		sigaddset( &mask, SIGUSR1 );			// block SIGUSR1 signals
 		sigsuspend( &mask );				// block the processor to prevent further damage during abort
-		_exit( EXIT_FAILURE );				// if processor unblocks before it is killed, terminate it		
-	}
-
-	return this_thread();
+		_exit( EXIT_FAILURE );				// if processor unblocks before it is killed, terminate it
+	}
+
+	return this_thread;
 }
 
@@ -494,8 +558,8 @@
 	__lib_debug_write( STDERR_FILENO, abort_text, len );
 
-	if ( thrd != this_coroutine() ) {
-		len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine()->name, this_coroutine() );
+	if ( thrd != this_coroutine ) {
+		len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine->name, this_coroutine );
 		__lib_debug_write( STDERR_FILENO, abort_text, len );
-	} 
+	}
 	else {
 		__lib_debug_write( STDERR_FILENO, ".\n", 2 );
@@ -505,9 +569,9 @@
 extern "C" {
 	void __lib_debug_acquire() {
-		lock(&kernel_debug_lock);
+		lock( &kernel_debug_lock DEBUG_CTX2 );
 	}
 
 	void __lib_debug_release() {
-		unlock(&kernel_debug_lock);
+		unlock( &kernel_debug_lock );
 	}
 }
@@ -525,13 +589,29 @@
 }
 
-bool try_lock( spinlock * this ) {
+bool try_lock( spinlock * this DEBUG_CTX_PARAM2 ) {
 	return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
 }
 
-void lock( spinlock * this ) {
+void lock( spinlock * this DEBUG_CTX_PARAM2 ) {
 	for ( unsigned int i = 1;; i += 1 ) {
-	  	if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) break;
-	}
-}
+		if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
+	}
+	LIB_DEBUG_DO(
+		this->prev_name = caller;
+		this->prev_thrd = this_thread;
+	)
+}
+
+void lock_yield( spinlock * this DEBUG_CTX_PARAM2 ) {
+	for ( unsigned int i = 1;; i += 1 ) {
+		if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
+		yield();
+	}
+	LIB_DEBUG_DO(
+		this->prev_name = caller;
+		this->prev_thrd = this_thread;
+	)
+}
+
 
 void unlock( spinlock * this ) {
@@ -539,32 +619,39 @@
 }
 
-void ?{}( signal_once * this ) {
-	this->cond = false;
-}
-void ^?{}( signal_once * this ) {
-
-}
-
-void wait( signal_once * this ) {
-	lock( &this->lock );
-	if( !this->cond ) {
-		append( &this->blocked, this_thread() );
-		ScheduleInternal( &this->lock );
-		lock( &this->lock );
-	}
+void  ?{}( semaphore * this, int count = 1 ) {
+	(&this->lock){};
+	this->count = count;
+	(&this->waiting){};
+}
+void ^?{}(semaphore * this) {}
+
+void P(semaphore * this) {
+	lock( &this->lock DEBUG_CTX2 );
+	this->count -= 1;
+	if ( this->count < 0 ) {
+		// queue current task
+		append( &this->waiting, (thread_desc *)this_thread );
+
+		// atomically release spin lock and block
+		BlockInternal( &this->lock );
+	}
+	else {
+	    unlock( &this->lock );
+	}
+}
+
+void V(semaphore * this) {
+	thread_desc * thrd = NULL;
+	lock( &this->lock DEBUG_CTX2 );
+	this->count += 1;
+	if ( this->count <= 0 ) {
+		// remove task at head of waiting list
+		thrd = pop_head( &this->waiting );
+	}
+
 	unlock( &this->lock );
-}
-
-void signal( signal_once * this ) {
-	lock( &this->lock );
-	{
-		this->cond = true;
-
-		thread_desc * it;
-		while( it = pop_head( &this->blocked) ) {
-			ScheduleThread( it );
-		}
-	}
-	unlock( &this->lock );
+
+	// make new owner
+	WakeThread( thrd );
 }
 
@@ -590,5 +677,5 @@
 		}
 		head->next = NULL;
-	}	
+	}
 	return head;
 }
@@ -609,5 +696,5 @@
 		this->top = top->next;
 		top->next = NULL;
-	}	
+	}
 	return top;
 }
Index: src/libcfa/concurrency/kernel_private.h
===================================================================
--- src/libcfa/concurrency/kernel_private.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/kernel_private.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -18,4 +18,6 @@
 #define KERNEL_PRIVATE_H
 
+#include "libhdr.h"
+
 #include "kernel"
 #include "thread"
@@ -23,17 +25,31 @@
 #include "alarm.h"
 
-#include "libhdr.h"
 
 //-----------------------------------------------------------------------------
 // Scheduler
+
+extern "C" {
+	void disable_interrupts();
+	void enable_interrupts_noRF();
+	void enable_interrupts( DEBUG_CTX_PARAM );
+}
+
 void ScheduleThread( thread_desc * );
+static inline void WakeThread( thread_desc * thrd ) {
+	if( !thrd ) return;
+
+	disable_interrupts();
+	ScheduleThread( thrd );
+	enable_interrupts( DEBUG_CTX );
+}
 thread_desc * nextThread(cluster * this);
 
-void ScheduleInternal(void);
-void ScheduleInternal(spinlock * lock);
-void ScheduleInternal(thread_desc * thrd);
-void ScheduleInternal(spinlock * lock, thread_desc * thrd);
-void ScheduleInternal(spinlock ** locks, unsigned short count);
-void ScheduleInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count);
+void BlockInternal(void);
+void BlockInternal(spinlock * lock);
+void BlockInternal(thread_desc * thrd);
+void BlockInternal(spinlock * lock, thread_desc * thrd);
+void BlockInternal(spinlock ** locks, unsigned short count);
+void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count);
+void LeaveThread(spinlock * lock, thread_desc * thrd);
 
 //-----------------------------------------------------------------------------
@@ -60,24 +76,9 @@
 extern cluster * systemCluster;
 extern system_proc_t * systemProcessor;
-extern thread_local processor * this_processor;
-
-static inline void disable_interrupts() {
-	__attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, 1, __ATOMIC_SEQ_CST );
-	assert( prev != (unsigned short) -1 );
-}
-
-static inline void enable_interrupts_noRF() {
-	__attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
-	verify( prev != (unsigned short) 0 );
-}
-
-static inline void enable_interrupts() {
-	__attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
-	verify( prev != (unsigned short) 0 );
-	if( prev == 1 && this_processor->pending_preemption ) {
-		ScheduleInternal( this_processor->current_thread );
-		this_processor->pending_preemption = false;
-	}
-}
+extern volatile thread_local processor * this_processor;
+extern volatile thread_local coroutine_desc * this_coroutine;
+extern volatile thread_local thread_desc * this_thread;
+extern volatile thread_local bool preemption_in_progress;
+extern volatile thread_local unsigned short disable_preempt_count;
 
 //-----------------------------------------------------------------------------
Index: src/libcfa/concurrency/monitor
===================================================================
--- src/libcfa/concurrency/monitor	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/monitor	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -26,5 +26,4 @@
 static inline void ?{}(monitor_desc * this) {
 	this->owner = NULL;
-	this->stack_owner = NULL;
 	this->recursion = 0;
 }
Index: src/libcfa/concurrency/monitor.c
===================================================================
--- src/libcfa/concurrency/monitor.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/monitor.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -19,6 +19,6 @@
 #include <stdlib>
 
+#include "libhdr.h"
 #include "kernel_private.h"
-#include "libhdr.h"
 
 //-----------------------------------------------------------------------------
@@ -44,9 +44,9 @@
 
 extern "C" {
-	void __enter_monitor_desc(monitor_desc * this) {
-		lock( &this->lock );
-		thread_desc * thrd = this_thread();
-
-		LIB_DEBUG_PRINT_SAFE("%p Entering %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion);
+	void __enter_monitor_desc( monitor_desc * this ) {
+		lock_yield( &this->lock DEBUG_CTX2 );
+		thread_desc * thrd = this_thread;
+
+		// LIB_DEBUG_PRINT_SAFE("%p Entering %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion);
 
 		if( !this->owner ) {
@@ -62,9 +62,9 @@
 			//Some one else has the monitor, wait in line for it
 			append( &this->entry_queue, thrd );
-			LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd);
-			ScheduleInternal( &this->lock );
-
-			//ScheduleInternal will unlock spinlock, no need to unlock ourselves
-			return; 
+			// LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd);
+			BlockInternal( &this->lock );
+
+			//BlockInternal will unlock spinlock, no need to unlock ourselves
+			return;
 		}
 
@@ -75,9 +75,9 @@
 	// leave pseudo code :
 	//	TODO
-	void __leave_monitor_desc(monitor_desc * this) {
-		lock( &this->lock );
-
-		LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion);
-		verifyf( this_thread() == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread(), this->owner, this->recursion );
+	void __leave_monitor_desc( monitor_desc * this ) {
+		lock_yield( &this->lock DEBUG_CTX2 );
+
+		// LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i). ", this_thread, this, this->owner, this->recursion);
+		verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread, this->owner, this->recursion );
 
 		//Leaving a recursion level, decrement the counter
@@ -96,8 +96,33 @@
 		unlock( &this->lock );
 
-		LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner);
+		// LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner);
 
 		//We need to wake-up the thread
-		ScheduleThread( new_owner );
+		WakeThread( new_owner );
+	}
+
+	void __leave_thread_monitor( thread_desc * thrd ) {
+		monitor_desc * this = &thrd->mon;
+		lock_yield( &this->lock DEBUG_CTX2 );
+
+		disable_interrupts();
+
+		thrd->cor.state = Halted;
+
+		verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
+
+		//Leaving a recursion level, decrement the counter
+		this->recursion -= 1;
+
+		//If we haven't left the last level of recursion
+		//it means we don't need to do anything
+		if( this->recursion != 0) {
+			unlock( &this->lock );
+			return;
+		}
+
+		thread_desc * new_owner = next_thread( this );
+
+		LeaveThread( &this->lock, new_owner );
 	}
 }
@@ -121,9 +146,9 @@
 	enter( this->m, this->count );
 
-	this->prev_mntrs = this_thread()->current_monitors;
-	this->prev_count = this_thread()->current_monitor_count;
-
-	this_thread()->current_monitors      = m;
-	this_thread()->current_monitor_count = count;
+	this->prev_mntrs = this_thread->current_monitors;
+	this->prev_count = this_thread->current_monitor_count;
+
+	this_thread->current_monitors      = m;
+	this_thread->current_monitor_count = count;
 }
 
@@ -131,6 +156,6 @@
 	leave( this->m, this->count );
 
-	this_thread()->current_monitors      = this->prev_mntrs;
-	this_thread()->current_monitor_count = this->prev_count;
+	this_thread->current_monitors      = this->prev_mntrs;
+	this_thread->current_monitor_count = this->prev_count;
 }
 
@@ -159,5 +184,5 @@
 // Internal scheduling
 void wait( condition * this, uintptr_t user_info = 0 ) {
-	LIB_DEBUG_PRINT_SAFE("Waiting\n");
+	// LIB_DEBUG_PRINT_SAFE("Waiting\n");
 
 	brand_condition( this );
@@ -170,14 +195,14 @@
 	unsigned short count = this->monitor_count;
 	unsigned int recursions[ count ];		//Save the current recursion levels to restore them later
-	spinlock *   locks     [ count ];		//We need to pass-in an array of locks to ScheduleInternal
-
-	LIB_DEBUG_PRINT_SAFE("count %i\n", count);
-
-	__condition_node_t waiter = { this_thread(), count, user_info };
+	spinlock *   locks     [ count ];		//We need to pass-in an array of locks to BlockInternal
+
+	// LIB_DEBUG_PRINT_SAFE("count %i\n", count);
+
+	__condition_node_t waiter = { (thread_desc*)this_thread, count, user_info };
 
 	__condition_criterion_t criteria[count];
 	for(int i = 0; i < count; i++) {
 		(&criteria[i]){ this->monitors[i], &waiter };
-		LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
+		// LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
 	}
 
@@ -201,12 +226,12 @@
 	}
 
-	LIB_DEBUG_PRINT_SAFE("Will unblock: ");
+	// LIB_DEBUG_PRINT_SAFE("Will unblock: ");
 	for(int i = 0; i < thread_count; i++) {
-		LIB_DEBUG_PRINT_SAFE("%p ", threads[i]);
-	}
-	LIB_DEBUG_PRINT_SAFE("\n");
+		// LIB_DEBUG_PRINT_SAFE("%p ", threads[i]);
+	}
+	// LIB_DEBUG_PRINT_SAFE("\n");
 
 	// Everything is ready to go to sleep
-	ScheduleInternal( locks, count, threads, thread_count );
+	BlockInternal( locks, count, threads, thread_count );
 
 
@@ -222,5 +247,5 @@
 bool signal( condition * this ) {
 	if( is_empty( this ) ) {
-		LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
+		// LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
 		return false;
 	}
@@ -231,8 +256,8 @@
 
 	unsigned short count = this->monitor_count;
-	
+
 	//Some more checking in debug
 	LIB_DEBUG_DO(
-		thread_desc * this_thrd = this_thread();
+		thread_desc * this_thrd = this_thread;
 		if ( this->monitor_count != this_thrd->current_monitor_count ) {
 			abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->current_monitor_count );
@@ -248,5 +273,5 @@
 	//Lock all the monitors
 	lock_all( this->monitors, NULL, count );
-	LIB_DEBUG_PRINT_SAFE("Signalling");
+	// LIB_DEBUG_PRINT_SAFE("Signalling");
 
 	//Pop the head of the waiting queue
@@ -256,10 +281,10 @@
 	for(int i = 0; i < count; i++) {
 		__condition_criterion_t * crit = &node->criteria[i];
-		LIB_DEBUG_PRINT_SAFE(" %p", crit->target);
+		// LIB_DEBUG_PRINT_SAFE(" %p", crit->target);
 		assert( !crit->ready );
 		push( &crit->target->signal_stack, crit );
 	}
 
-	LIB_DEBUG_PRINT_SAFE("\n");
+	// LIB_DEBUG_PRINT_SAFE("\n");
 
 	//Release
@@ -281,15 +306,15 @@
 	unsigned short count = this->monitor_count;
 	unsigned int recursions[ count ];		//Save the current recursion levels to restore them later
-	spinlock *   locks     [ count ];		//We need to pass-in an array of locks to ScheduleInternal
+	spinlock *   locks     [ count ];		//We need to pass-in an array of locks to BlockInternal
 
 	lock_all( this->monitors, locks, count );
 
 	//create creteria
-	__condition_node_t waiter = { this_thread(), count, 0 };
+	__condition_node_t waiter = { (thread_desc*)this_thread, count, 0 };
 
 	__condition_criterion_t criteria[count];
 	for(int i = 0; i < count; i++) {
 		(&criteria[i]){ this->monitors[i], &waiter };
-		LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
+		// LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
 		push( &criteria[i].target->signal_stack, &criteria[i] );
 	}
@@ -309,5 +334,5 @@
 
 	//Everything is ready to go to sleep
-	ScheduleInternal( locks, count, &signallee, 1 );
+	BlockInternal( locks, count, &signallee, 1 );
 
 
@@ -325,5 +350,5 @@
 
 uintptr_t front( condition * this ) {
-	verifyf( !is_empty(this), 
+	verifyf( !is_empty(this),
 		"Attempt to access user data on an empty condition.\n"
 		"Possible cause is not checking if the condition is empty before reading stored data."
@@ -335,9 +360,9 @@
 // Internal scheduling
 void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ) {
-	// thread_desc * this = this_thread();
+	// thread_desc * this = this_thread;
 
 	// unsigned short count = this->current_monitor_count;
 	// unsigned int recursions[ count ];		//Save the current recursion levels to restore them later
-	// spinlock *   locks     [ count ];		//We need to pass-in an array of locks to ScheduleInternal
+	// spinlock *   locks     [ count ];		//We need to pass-in an array of locks to BlockInternal
 
 	// lock_all( this->current_monitors, locks, count );
@@ -348,5 +373,5 @@
 
 	// // // Everything is ready to go to sleep
-	// // ScheduleInternal( locks, count, threads, thread_count );
+	// // BlockInternal( locks, count, threads, thread_count );
 
 
@@ -393,5 +418,5 @@
 static inline void lock_all( spinlock ** locks, unsigned short count ) {
 	for( int i = 0; i < count; i++ ) {
-		lock( locks[i] );
+		lock_yield( locks[i] DEBUG_CTX2 );
 	}
 }
@@ -400,5 +425,5 @@
 	for( int i = 0; i < count; i++ ) {
 		spinlock * l = &source[i]->lock;
-		lock( l );
+		lock_yield( l DEBUG_CTX2 );
 		if(locks) locks[i] = l;
 	}
@@ -443,8 +468,8 @@
 	for(	int i = 0; i < count; i++ ) {
 
-		LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target );
+		// LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target );
 		if( &criteria[i] == target ) {
 			criteria[i].ready = true;
-			LIB_DEBUG_PRINT_SAFE( "True\n" );
+			// LIB_DEBUG_PRINT_SAFE( "True\n" );
 		}
 
@@ -452,12 +477,12 @@
 	}
 
-	LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run );
+	// LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run );
 	return ready2run ? node->waiting_thread : NULL;
 }
 
 static inline void brand_condition( condition * this ) {
-	thread_desc * thrd = this_thread();
+	thread_desc * thrd = this_thread;
 	if( !this->monitors ) {
-		LIB_DEBUG_PRINT_SAFE("Branding\n");
+		// LIB_DEBUG_PRINT_SAFE("Branding\n");
 		assertf( thrd->current_monitors != NULL, "No current monitor to brand condition", thrd->current_monitors );
 		this->monitor_count = thrd->current_monitor_count;
Index: src/libcfa/concurrency/preemption.c
===================================================================
--- src/libcfa/concurrency/preemption.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/preemption.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -15,11 +15,24 @@
 //
 
+#include "libhdr.h"
 #include "preemption.h"
 
 extern "C" {
+#include <errno.h>
+#include <execinfo.h>
+#define __USE_GNU
 #include <signal.h>
-}
-
-#define __CFA_DEFAULT_PREEMPTION__ 10
+#undef __USE_GNU
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+}
+
+
+#ifdef __USE_STREAM__
+#include "fstream"
+#endif
+
+#define __CFA_DEFAULT_PREEMPTION__ 10000
 
 __attribute__((weak)) unsigned int default_preemption() {
@@ -27,20 +40,38 @@
 }
 
+#define __CFA_SIGCXT__ ucontext_t *
+#define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt
+
 static void preempt( processor   * this );
 static void timeout( thread_desc * this );
 
+void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
+void sigHandler_alarm    ( __CFA_SIGPARMS__ );
+void sigHandler_segv     ( __CFA_SIGPARMS__ );
+void sigHandler_abort    ( __CFA_SIGPARMS__ );
+
+static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags );
+LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
+
+#ifdef __x86_64__
+#define CFA_REG_IP REG_RIP
+#else
+#define CFA_REG_IP REG_EIP
+#endif
+
+
 //=============================================================================================
 // Kernel Preemption logic
 //=============================================================================================
 
-void kernel_start_preemption() {
-
-}
-
 void tick_preemption() {
+	// LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Ticking preemption\n" );
+
 	alarm_list_t * alarms = &systemProcessor->alarms;
 	__cfa_time_t currtime = __kernel_get_time();
 	while( alarms->head && alarms->head->alarm < currtime ) {
 		alarm_node_t * node = pop(alarms);
+		// LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking %p\n", node );
+
 		if( node->kernel_alarm ) {
 			preempt( node->proc );
@@ -50,6 +81,8 @@
 		}
 
+		verify( validate( alarms ) );
+
 		if( node->period > 0 ) {
-			node->alarm += node->period;
+			node->alarm = currtime + node->period;
 			insert( alarms, node );
 		}
@@ -62,9 +95,14 @@
 		__kernel_set_timer( alarms->head->alarm - currtime );
 	}
+
+	verify( validate( alarms ) );
+	// LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking preemption done\n" );
 }
 
 void update_preemption( processor * this, __cfa_time_t duration ) {
-	//     assert( THREAD_GETMEM( disableInt ) && THREAD_GETMEM( disableIntCnt ) == 1 );
+	LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p updating preemption to %lu\n", this, duration );
+
 	alarm_node_t * alarm = this->preemption_alarm;
+	duration *= 1000;
 
 	// Alarms need to be enabled
@@ -89,4 +127,107 @@
 }
 
+//=============================================================================================
+// Kernel Signal Tools
+//=============================================================================================
+
+LIB_DEBUG_DO( static thread_local void * last_interrupt = 0; )
+
+extern "C" {
+	void disable_interrupts() {
+		__attribute__((unused)) unsigned short new_val = __atomic_add_fetch_2( &disable_preempt_count, 1, __ATOMIC_SEQ_CST );
+		verify( new_val < (unsigned short)65_000 );
+		verify( new_val != (unsigned short) 0 );
+	}
+
+	void enable_interrupts_noRF() {
+		__attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
+		verify( prev != (unsigned short) 0 );
+	}
+
+	void enable_interrupts( DEBUG_CTX_PARAM ) {
+		processor * proc   = this_processor;
+		thread_desc * thrd = this_thread;
+		unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
+		verify( prev != (unsigned short) 0 );
+		if( prev == 1 && proc->pending_preemption ) {
+			proc->pending_preemption = false;
+			BlockInternal( thrd );
+		}
+
+		LIB_DEBUG_DO( proc->last_enable = caller; )
+	}
+}
+
+static inline void signal_unblock( int sig ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, sig );
+
+	if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
+	    abortf( "internal error, pthread_sigmask" );
+	}
+}
+
+static inline void signal_block( int sig ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, sig );
+
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abortf( "internal error, pthread_sigmask" );
+	}
+}
+
+static inline bool preemption_ready() {
+	return disable_preempt_count == 0 && !preemption_in_progress;
+}
+
+static inline void defer_ctxSwitch() {
+	this_processor->pending_preemption = true;
+}
+
+static inline void defer_alarm() {
+	systemProcessor->pending_alarm = true;
+}
+
+static void preempt( processor * this ) {
+	pthread_kill( this->kernel_thread, SIGUSR1 );
+}
+
+static void timeout( thread_desc * this ) {
+	//TODO : implement waking threads
+}
+
+//=============================================================================================
+// Kernel Signal Startup/Shutdown logic
+//=============================================================================================
+
+static pthread_t alarm_thread;
+void * alarm_loop( __attribute__((unused)) void * args );
+
+void kernel_start_preemption() {
+	LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
+	__kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
+	// __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
+	// __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
+
+	signal_block( SIGALRM );
+
+	pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
+}
+
+void kernel_stop_preemption() {
+	LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopping\n");
+
+	sigset_t mask;
+	sigfillset( &mask );
+	sigprocmask( SIG_BLOCK, &mask, NULL );
+
+	sigval val = { 1 };
+	pthread_sigqueue( alarm_thread, SIGALRM, val );
+	pthread_join( alarm_thread, NULL );
+	LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
+}
+
 void ?{}( preemption_scope * this, processor * proc ) {
 	(&this->alarm){ proc };
@@ -97,26 +238,21 @@
 
 void ^?{}( preemption_scope * this ) {
+	disable_interrupts();
+
 	update_preemption( this->proc, 0 );
 }
 
 //=============================================================================================
-// Kernel Signal logic
-//=============================================================================================
-
-static inline bool preemption_ready() {
-	return this_processor->disable_preempt_count == 0;
-}
-
-static inline void defer_ctxSwitch() {
-	this_processor->pending_preemption = true;
-}
-
-static inline void defer_alarm() {
-	systemProcessor->pending_alarm = true;
-}
-
-void sigHandler_ctxSwitch( __attribute__((unused)) int sig ) {
+// Kernel Signal Handlers
+//=============================================================================================
+
+void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
+	LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
 	if( preemption_ready() ) {
-		ScheduleInternal( this_processor->current_thread );
+		preemption_in_progress = true;
+		signal_unblock( SIGUSR1 );
+		this_processor->pending_preemption = false;
+		preemption_in_progress = false;
+		BlockInternal( (thread_desc*)this_thread );
 	}
 	else {
@@ -125,19 +261,170 @@
 }
 
-void sigHandler_alarm( __attribute__((unused)) int sig ) {
-	if( try_lock( &systemProcessor->alarm_lock ) ) {
-		tick_preemption();
-		unlock( &systemProcessor->alarm_lock );
-	}
-	else {
-		defer_alarm();
-	}
-}
-
-static void preempt( processor * this ) {
-	pthread_kill( this->kernel_thread, SIGUSR1 );
-}
-
-static void timeout( thread_desc * this ) {
-	//TODO : implement waking threads
-}
+void * alarm_loop( __attribute__((unused)) void * args ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, SIGALRM );
+
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abortf( "internal error, pthread_sigmask" );
+	}
+
+	while( true ) {
+		siginfo_t info;
+		int sig = sigwaitinfo( &mask, &info );
+		if( sig < 0 ) {
+			abortf( "internal error, sigwait" );
+		}
+		else if( sig == SIGALRM )
+		{
+			LIB_DEBUG_PRINT_SAFE("Kernel : Caught signal %d (%d)\n", sig, info.si_value.sival_int );
+			if( info.si_value.sival_int == 0 )
+			{
+				LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
+				lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
+				tick_preemption();
+				unlock( &systemProcessor->alarm_lock );
+			}
+			else if( info.si_value.sival_int == 1 )
+			{
+				break;
+			}
+		}
+		else
+		{
+			LIB_DEBUG_PRINT_SAFE("Kernel : Unexpected signal %d (%d)\n", sig, info.si_value.sival_int);
+		}
+	}
+
+	LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n");
+	return NULL;
+}
+
+static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
+	struct sigaction act;
+
+	act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
+	act.sa_flags = flags;
+
+	if ( sigaction( sig, &act, NULL ) == -1 ) {
+		LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,
+			" __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
+			sig, handler, flags, errno, strerror( errno )
+		);
+		_exit( EXIT_FAILURE );
+	}
+}
+
+typedef void (*sa_handler_t)(int);
+
+static void __kernel_sigdefault( int sig ) {
+	struct sigaction act;
+
+	// act.sa_handler = SIG_DFL;
+	act.sa_flags = 0;
+	sigemptyset( &act.sa_mask );
+
+	if ( sigaction( sig, &act, NULL ) == -1 ) {
+		LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,
+			" __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
+			sig, errno, strerror( errno )
+		);
+		_exit( EXIT_FAILURE );
+	}
+}
+
+//=============================================================================================
+// Terminating Signals logic
+//=============================================================================================
+
+LIB_DEBUG_DO(
+	static void __kernel_backtrace( int start ) {
+		// skip first N stack frames
+
+		enum { Frames = 50 };
+		void * array[Frames];
+		int size = backtrace( array, Frames );
+		char ** messages = backtrace_symbols( array, size );
+
+		// find executable name
+		*index( messages[0], '(' ) = '\0';
+		#ifdef __USE_STREAM__
+		serr | "Stack back trace for:" | messages[0] | endl;
+		#else
+		fprintf( stderr, "Stack back trace for: %s\n", messages[0]);
+		#endif
+
+		// skip last 2 stack frames after main
+		for ( int i = start; i < size && messages != NULL; i += 1 ) {
+			char * name = NULL;
+			char * offset_begin = NULL;
+			char * offset_end = NULL;
+
+			for ( char *p = messages[i]; *p; ++p ) {
+				// find parantheses and +offset
+				if ( *p == '(' ) {
+					name = p;
+				}
+				else if ( *p == '+' ) {
+					offset_begin = p;
+				}
+				else if ( *p == ')' ) {
+					offset_end = p;
+					break;
+				}
+			}
+
+			// if line contains symbol print it
+			int frameNo = i - start;
+			if ( name && offset_begin && offset_end && name < offset_begin ) {
+				// delimit strings
+				*name++ = '\0';
+				*offset_begin++ = '\0';
+				*offset_end++ = '\0';
+
+				#ifdef __USE_STREAM__
+				serr 	| "("  | frameNo | ")" | messages[i] | ":"
+					| name | "+" | offset_begin | offset_end | endl;
+				#else
+				fprintf( stderr, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
+				#endif
+			}
+			// otherwise, print the whole line
+			else {
+				#ifdef __USE_STREAM__
+				serr | "(" | frameNo | ")" | messages[i] | endl;
+				#else
+				fprintf( stderr, "(%i) %s\n", frameNo, messages[i] );
+				#endif
+			}
+		}
+
+		free( messages );
+	}
+)
+
+// void sigHandler_segv( __CFA_SIGPARMS__ ) {
+// 	LIB_DEBUG_DO(
+// 		#ifdef __USE_STREAM__
+// 		serr 	| "*CFA runtime error* program cfa-cpp terminated with"
+// 			| (sig == SIGSEGV ? "segment fault." : "bus error.")
+// 			| endl;
+// 		#else
+// 		fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );
+// 		#endif
+
+// 		// skip first 2 stack frames
+// 		__kernel_backtrace( 1 );
+// 	)
+// 	exit( EXIT_FAILURE );
+// }
+
+// void sigHandler_abort( __CFA_SIGPARMS__ ) {
+// 	// skip first 6 stack frames
+// 	LIB_DEBUG_DO( __kernel_backtrace( 6 ); )
+
+// 	// reset default signal handler
+// 	__kernel_sigdefault( SIGABRT );
+
+// 	raise( SIGABRT );
+// }
Index: src/libcfa/concurrency/thread
===================================================================
--- src/libcfa/concurrency/thread	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/thread	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -54,5 +54,5 @@
 }
 
-thread_desc * this_thread(void);
+extern volatile thread_local thread_desc * this_thread;
 
 forall( dtype T | is_thread(T) )
Index: src/libcfa/concurrency/thread.c
===================================================================
--- src/libcfa/concurrency/thread.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/concurrency/thread.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -28,5 +28,5 @@
 }
 
-extern thread_local processor * this_processor;
+extern volatile thread_local processor * this_processor;
 
 //-----------------------------------------------------------------------------
@@ -71,18 +71,21 @@
 	coroutine_desc* thrd_c = get_coroutine(this);
 	thread_desc*  thrd_h = get_thread   (this);
-	thrd_c->last = this_coroutine();
-	this_processor->current_coroutine = thrd_c;
+	thrd_c->last = this_coroutine;
 
-	LIB_DEBUG_PRINT_SAFE("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
+	// LIB_DEBUG_PRINT_SAFE("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
 
+	disable_interrupts();
 	create_stack(&thrd_c->stack, thrd_c->stack.size);
+	this_coroutine = thrd_c;
 	CtxStart(this, CtxInvokeThread);
+	assert( thrd_c->last->stack.context );
 	CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context );
 
 	ScheduleThread(thrd_h);
+	enable_interrupts( DEBUG_CTX );
 }
 
 void yield( void ) {
-	ScheduleInternal( this_processor->current_thread );
+	BlockInternal( (thread_desc *)this_thread );
 }
 
@@ -95,5 +98,5 @@
 void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
 	// set state of current coroutine to inactive
-	src->state = Inactive;
+	src->state = src->state == Halted ? Halted : Inactive;
 	dst->state = Active;
 
@@ -103,10 +106,11 @@
 	// set new coroutine that the processor is executing
 	// and context switch to it
-	this_processor->current_coroutine = dst;
+	this_coroutine = dst;
+	assert( src->stack.context );
 	CtxSwitch( src->stack.context, dst->stack.context );
-	this_processor->current_coroutine = src;
+	this_coroutine = src;
 
 	// set state of new coroutine to active
-	dst->state = Inactive;
+	dst->state = dst->state == Halted ? Halted : Inactive;
 	src->state = Active;
 }
Index: src/libcfa/exception.c
===================================================================
--- src/libcfa/exception.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/exception.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:13:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Mon Nov 26 15:11:00 2017
-// Update Count     : 0
+// Last Modified On : Tus Jul 11 16:36:00 2017
+// Update Count     : 1
 //
 
@@ -44,5 +44,5 @@
 // RESUMPTION ================================================================
 
-void __cfaehm__throw_resumption(exception * except) {
+void __cfaehm__throw_resume(exception * except) {
 
 	// DEBUG
@@ -65,5 +65,5 @@
 
 	// Fall back to termination:
-	__cfaehm__throw_termination(except);
+	__cfaehm__throw_terminate(except);
 	// TODO: Default handler for resumption.
 }
@@ -111,5 +111,5 @@
 }
 
-void __cfaehm__throw_termination( exception * val ) {
+void __cfaehm__throw_terminate( exception * val ) {
 	// Store the current exception
 	shared_stack.current_exception = *val;
@@ -147,9 +147,9 @@
 
 // Nesting this the other way would probably be faster.
-void __cfaehm__rethrow_termination(void) {
+void __cfaehm__rethrow_terminate(void) {
 	// DEBUG
 	printf("Rethrowing termination exception\n");
 
-	__cfaehm__throw_termination(&shared_stack.current_exception);
+	__cfaehm__throw_terminate(&shared_stack.current_exception);
 }
 
Index: src/libcfa/exception.h
===================================================================
--- src/libcfa/exception.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/exception.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:11:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Mon Nov 26 15:11:00 2017
-// Update Count     : 0
+// Last Modified On : Tus Jul 11 16:31:00 2017
+// Update Count     : 2
 //
 
@@ -22,11 +22,11 @@
 
 #ifdef __CFORALL__
-extern "BuiltinC" {
+extern "C" {
 #endif
 
 // Used in throw statement translation.
-void __cfaehm__throw_termination(exception * except) __attribute__((noreturn));
-void __cfaehm__rethrow_termination() __attribute__((noreturn));
-void __cfaehm__throw_resumption(exception * except);
+void __cfaehm__throw_terminate(exception * except) __attribute__((noreturn));
+void __cfaehm__rethrow_terminate() __attribute__((noreturn));
+void __cfaehm__throw_resume(exception * except);
 
 // Function catches termination exceptions.
Index: src/libcfa/fstream
===================================================================
--- src/libcfa/fstream	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/fstream	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,22 +10,21 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jul  1 16:37:53 2017
-// Update Count     : 112
+// Last Modified On : Fri Jul  7 08:32:38 2017
+// Update Count     : 117
 //
 
-#ifndef __FSTREAM_H__
-#define __FSTREAM_H__
+#pragma once
 
 #include "iostream"
 
-enum { separateSize = 16 };
+enum { sepSize = 16 };
 struct ofstream {
 	void * file;
 	_Bool sepDefault;
 	_Bool sepOnOff;
-	_Bool lastSepOn;
+	_Bool sawNL;
 	const char * sepCur;
-	char separator[separateSize];
-	char tupleSeparator[separateSize];
+	char separator[sepSize];
+	char tupleSeparator[sepSize];
 }; // ofstream
 
@@ -36,5 +35,6 @@
 const char * sepGetCur( ofstream * );
 void sepSetCur( ofstream *, const char * );
-_Bool lastSepOn( ofstream * );
+_Bool getNL( ofstream * );
+void setNL( ofstream *, _Bool );
 
 // public
@@ -75,6 +75,4 @@
 extern ifstream * sin;
 
-#endif // __FSTREAM_H__
-
 // Local Variables: //
 // mode: c //
Index: src/libcfa/fstream.c
===================================================================
--- src/libcfa/fstream.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/fstream.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jul  1 16:37:54 2017
-// Update Count     : 242
+// Last Modified On : Thu Jul  6 18:38:25 2017
+// Update Count     : 251
 //
 
@@ -33,5 +33,4 @@
 	this->sepDefault = sepDefault;
 	this->sepOnOff = sepOnOff;
-	this->lastSepOn = false;
 	sepSet( this, separator );
 	sepSetCur( this, sepGet( this ) );
@@ -40,19 +39,19 @@
 
 // private
-_Bool lastSepOn( ofstream * os ) { return os->lastSepOn; }
-_Bool sepPrt( ofstream * os ) { os->lastSepOn = false; return os->sepOnOff; }
+_Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
 const char * sepGetCur( ofstream * os ) { return os->sepCur; }
 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
+_Bool getNL( ofstream * os ) { return os->sawNL; }
+void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
 
 // public
-void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; }
-void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; }
+void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
+void sepOff( ofstream * os ) { os->sepOnOff = false; }
 
 _Bool sepDisable( ofstream *os ) {
 	_Bool temp = os->sepDefault;
 	os->sepDefault = false;
-	os->lastSepOn = false;
 	sepReset( os );
 	return temp;
@@ -69,6 +68,6 @@
 void sepSet( ofstream * os, const char * s ) {
 	assert( s );
-	strncpy( os->separator, s, separateSize - 1 );
-	os->separator[separateSize - 1] = '\0';
+	strncpy( os->separator, s, sepSize - 1 );
+	os->separator[sepSize - 1] = '\0';
 } // sepSet
 
@@ -76,6 +75,6 @@
 void sepSetTuple( ofstream * os, const char * s ) {
 	assert( s );
-	strncpy( os->tupleSeparator, s, separateSize - 1 );
-	os->tupleSeparator[separateSize - 1] = '\0';
+	strncpy( os->tupleSeparator, s, sepSize - 1 );
+	os->tupleSeparator[sepSize - 1] = '\0';
 } // sepSet
 
@@ -153,11 +152,11 @@
 
 void open( ifstream * is, const char * name, const char * mode ) {
-	FILE *t = fopen( name, mode );
-	if ( t == 0 ) {										// do not change unless successful
+	FILE *file = fopen( name, mode );
+	if ( file == 0 ) {									// do not change unless successful
 		fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
 		perror( 0 );
 		exit( EXIT_FAILURE );
 	} // if
-	is->file = t;
+	is->file = file;
 } // open
 
Index: src/libcfa/gmp
===================================================================
--- src/libcfa/gmp	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/gmp	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,9 +10,11 @@
 // Created On       : Tue Apr 19 08:43:43 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May 27 09:55:51 2017
-// Update Count     : 14
+// Last Modified On : Fri Jul  7 09:33:20 2017
+// Update Count     : 15
 // 
 
 // https://gmplib.org/gmp-man-6.1.1.pdf
+
+#pragma once
 
 #include <gmp.h>										// GNU multi-precise integers
Index: src/libcfa/iostream
===================================================================
--- src/libcfa/iostream	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/iostream	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,9 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jul  2 08:42:56 2017
-// Update Count     : 110
+// Last Modified On : Fri Jul  7 08:35:59 2017
+// Update Count     : 118
 //
 
-#ifndef __IOSTREAM_H__
-#define __IOSTREAM_H__
+#pragma once
 
 #include "iterator"
@@ -26,5 +25,6 @@
 	const char * sepGetCur( ostype * );					// get current separator string
 	void sepSetCur( ostype *, const char * );			// set current separator string
-	_Bool lastSepOn( ostype * );						// last manipulator is setOn (context sensitive)
+	_Bool getNL( ostype * );							// check newline
+	void setNL( ostype *, _Bool );						// saw newline
 	// public
 	void sepOn( ostype * );								// turn separator state on
@@ -82,4 +82,6 @@
 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) );
 forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
+forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype * );
+forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype * );
 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * );
 forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * );
@@ -137,6 +139,4 @@
 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );
 
-#endif // __IOSTREAM_H
-
 // Local Variables: //
 // mode: c //
Index: src/libcfa/iostream.c
===================================================================
--- src/libcfa/iostream.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/iostream.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jul  2 08:54:02 2017
-// Update Count     : 375
+// Last Modified On : Thu Jul  6 18:14:17 2017
+// Update Count     : 396
 //
 
@@ -18,4 +18,5 @@
 extern "C" {
 #include <stdio.h>
+#include <stdbool.h>									// true/false
 #include <string.h>										// strlen
 #include <float.h>										// DBL_DIG, LDBL_DIG
@@ -24,6 +25,7 @@
 
 forall( dtype ostype | ostream( ostype ) )
-ostype * ?|?( ostype * os, char c ) {
-	fmt( os, "%c", c );
+ostype * ?|?( ostype * os, char ch ) {
+	fmt( os, "%c", ch );
+	if ( ch == '\n' ) setNL( os, true );
 	sepOff( os );
 	return os;
@@ -180,6 +182,6 @@
 
 	// last character IS spacing or opening punctuation => turn off separator for next item
-	unsigned int len = strlen( cp ), posn = len - 1;
-	ch = cp[posn];										// must make unsigned
+	size_t len = strlen( cp );
+	ch = cp[len - 1];									// must make unsigned
 	if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
 		sepOn( os );
@@ -187,4 +189,5 @@
 		sepOff( os );
 	} // if
+	if ( ch == '\n' ) setNL( os, true );				// check *AFTER* sepPrt call above as it resets NL flag
 	return write( os, cp, len );
 } // ?|?
@@ -216,7 +219,19 @@
 
 forall( dtype ostype | ostream( ostype ) )
+ostype * sep( ostype * os ) {
+	os | sepGet( os );
+	return os;
+} // sep
+
+forall( dtype ostype | ostream( ostype ) )
+ostype * sepTuple( ostype * os ) {
+	os | sepGetTuple( os );
+	return os;
+} // sepTuple
+
+forall( dtype ostype | ostream( ostype ) )
 ostype * endl( ostype * os ) {
-	if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) );
 	os | '\n';
+	setNL( os, true );
 	flush( os );
 	sepOff( os );										// prepare for next line
Index: src/libcfa/iterator
===================================================================
--- src/libcfa/iterator	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/iterator	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,9 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Mar  2 18:06:05 2016
-// Update Count     : 9
+// Last Modified On : Fri Jul  7 08:37:25 2017
+// Update Count     : 10
 //
 
-#ifndef ITERATOR_H
-#define ITERATOR_H
+#pragma once
 
 // An iterator can be used to traverse a data structure.
@@ -39,10 +38,8 @@
 
 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
+void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
 
 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
-
-#endif // ITERATOR_H
+void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
 
 // Local Variables: //
Index: src/libcfa/iterator.c
===================================================================
--- src/libcfa/iterator.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/iterator.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Mar  2 18:08:11 2016
-// Update Count     : 27
+// Last Modified On : Fri Jul  7 08:38:23 2017
+// Update Count     : 28
 //
 
@@ -17,17 +17,17 @@
 
 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
+void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
 	for ( iterator_type i = begin; i != end; ++i ) {
 		func( *i );
-	}
-}
+	} // for
+} // for_each
 
 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
+void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
 	for ( iterator_type i = end; i != begin; ) {
 		--i;
 		func( *i );
-	}
-}
+	} // for
+} // for_each_reverse
 
 // Local Variables: //
Index: src/libcfa/libhdr/libalign.h
===================================================================
--- src/libcfa/libhdr/libalign.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/libhdr/libalign.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -1,3 +1,3 @@
-//                              -*- Mode: C++ -*- 
+//                              -*- Mode: C++ -*-
 //
 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
@@ -18,13 +18,13 @@
 // Free Software  Foundation; either  version 2.1 of  the License, or  (at your
 // option) any later version.
-// 
+//
 // This library is distributed in the  hope that it will be useful, but WITHOUT
 // ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 // for more details.
-// 
+//
 // You should  have received a  copy of the  GNU Lesser General  Public License
 // along  with this library.
-// 
+//
 
 
@@ -33,6 +33,7 @@
 
 #include "assert"
+#include <stdbool.h>
 
-// Minimum size used to align memory boundaries for memory allocations. 
+// Minimum size used to align memory boundaries for memory allocations.
 #define libAlign() (sizeof(double))
 
Index: src/libcfa/libhdr/libdebug.h
===================================================================
--- src/libcfa/libhdr/libdebug.h	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/libhdr/libdebug.h	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -18,9 +18,17 @@
 
 #ifdef __CFA_DEBUG__
-	#define LIB_DEBUG_DO(x) x
-	#define LIB_NO_DEBUG_DO(x) ((void)0)
+	#define LIB_DEBUG_DO(...) __VA_ARGS__
+	#define LIB_NO_DEBUG_DO(...)
+	#define DEBUG_CTX __PRETTY_FUNCTION__
+	#define DEBUG_CTX2 , __PRETTY_FUNCTION__
+	#define DEBUG_CTX_PARAM const char * caller
+	#define DEBUG_CTX_PARAM2 , const char * caller
 #else
-	#define LIB_DEBUG_DO(x) ((void)0)
-	#define LIB_NO_DEBUG_DO(x) x      
+	#define LIB_DEBUG_DO(...)
+	#define LIB_NO_DEBUG_DO(...) __VA_ARGS__
+	#define DEBUG_CTX
+	#define DEBUG_CTX2
+	#define DEBUG_CTX_PARAM
+	#define DEBUG_CTX_PARAM2
 #endif
 
@@ -51,17 +59,21 @@
 
 #ifdef __CFA_DEBUG_PRINT__
-      #define LIB_DEBUG_WRITE( fd, buffer, len )  __lib_debug_write( fd, buffer, len )
-      #define LIB_DEBUG_ACQUIRE()                 __lib_debug_acquire()
-      #define LIB_DEBUG_RELEASE()                 __lib_debug_release()
-      #define LIB_DEBUG_PRINT_SAFE(...)           __lib_debug_print_safe   (__VA_ARGS__)
-      #define LIB_DEBUG_PRINT_NOLOCK(...)         __lib_debug_print_nolock (__VA_ARGS__)
-      #define LIB_DEBUG_PRINT_BUFFER(...)         __lib_debug_print_buffer (__VA_ARGS__)
+	#define LIB_DEBUG_WRITE( fd, buffer, len )     __lib_debug_write( fd, buffer, len )
+	#define LIB_DEBUG_ACQUIRE()                    __lib_debug_acquire()
+	#define LIB_DEBUG_RELEASE()                    __lib_debug_release()
+	#define LIB_DEBUG_PRINT_SAFE(...)              __lib_debug_print_safe   (__VA_ARGS__)
+	#define LIB_DEBUG_PRINT_NOLOCK(...)            __lib_debug_print_nolock (__VA_ARGS__)
+	#define LIB_DEBUG_PRINT_BUFFER(...)            __lib_debug_print_buffer (__VA_ARGS__)
+	#define LIB_DEBUG_PRINT_BUFFER_DECL(fd, ...)   char text[256]; int len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text, len );
+	#define LIB_DEBUG_PRINT_BUFFER_LOCAL(fd, ...)  len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text, len );
 #else
-      #define LIB_DEBUG_WRITE(...)          ((void)0)
-      #define LIB_DEBUG_ACQUIRE()           ((void)0)
-      #define LIB_DEBUG_RELEASE()           ((void)0)
-      #define LIB_DEBUG_PRINT_SAFE(...)     ((void)0)
-      #define LIB_DEBUG_PRINT_NOLOCK(...)   ((void)0)
-      #define LIB_DEBUG_PRINT_BUFFER(...)   ((void)0)
+	#define LIB_DEBUG_WRITE(...)               ((void)0)
+	#define LIB_DEBUG_ACQUIRE()                ((void)0)
+	#define LIB_DEBUG_RELEASE()                ((void)0)
+	#define LIB_DEBUG_PRINT_SAFE(...)          ((void)0)
+	#define LIB_DEBUG_PRINT_NOLOCK(...)        ((void)0)
+	#define LIB_DEBUG_PRINT_BUFFER(...)        ((void)0)
+	#define LIB_DEBUG_PRINT_BUFFER_DECL(...)   ((void)0)
+	#define LIB_DEBUG_PRINT_BUFFER_LOCAL(...)  ((void)0)
 #endif
 
Index: src/libcfa/limits
===================================================================
--- src/libcfa/limits	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/limits	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,9 @@
 // Created On       : Wed Apr  6 18:06:52 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Apr  6 21:08:16 2016
-// Update Count     : 6
+// Last Modified On : Fri Jul  7 09:33:57 2017
+// Update Count     : 7
 //
 
-#ifndef LIMITS_H
-#define LIMITS_H
+#pragma once
 
 // Integral Constants
@@ -110,6 +109,4 @@
 extern const long _Complex _1_SQRT_2;					// 1 / sqrt(2)
 
-#endif // LIMITS_H
-
 // Local Variables: //
 // mode: c //
Index: src/libcfa/math
===================================================================
--- src/libcfa/math	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/math	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,9 @@
 // Created On       : Mon Apr 18 23:37:04 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 24 17:40:39 2017
-// Update Count     : 60
-//
-
-#ifndef MATH_H
-#define MATH_H
+// Last Modified On : Fri Jul  7 09:34:15 2017
+// Update Count     : 61
+//
+
+#pragma once
 
 extern "C" {
@@ -345,6 +344,4 @@
 long double scalbln( long double, long int );
 
-#endif // MATH_H
-
 // Local Variables: //
 // mode: c //
Index: src/libcfa/rational
===================================================================
--- src/libcfa/rational	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/rational	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -12,10 +12,9 @@
 // Created On       : Wed Apr  6 17:56:25 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon May 15 21:30:12 2017
-// Update Count     : 90
+// Last Modified On : Fri Jul  7 09:34:33 2017
+// Update Count     : 93
 //
 
-#ifndef RATIONAL_H
-#define RATIONAL_H
+#pragma once
 
 #include "iostream"
@@ -47,5 +46,5 @@
 // implementation
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 struct Rational {
 	RationalImpl numerator, denominator;				// invariant: denominator > 0
@@ -54,93 +53,92 @@
 // constructors
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, RationalImpl n );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, zero_t );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, one_t );
 
-// getter for numerator/denominator
+// numerator/denominator getter
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl numerator( Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl denominator( Rational(RationalImpl) r );
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
 
-// setter for numerator/denominator
+// numerator/denominator setter
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
 
 // comparison
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
 // arithmetic
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) +?( Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) -?( Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
 
 // conversion
-forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
 double widen( Rational(RationalImpl) r );
-forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
 Rational(RationalImpl) narrow( double f, RationalImpl md );
 
 // I/O
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
 istype * ?|?( istype *, Rational(RationalImpl) * );
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
 ostype * ?|?( ostype *, Rational(RationalImpl ) );
-
-#endif // RATIONAL_H
 
 // Local Variables: //
Index: src/libcfa/rational.c
===================================================================
--- src/libcfa/rational.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/rational.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Apr  6 17:54:28 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon May 15 21:29:23 2017
-// Update Count     : 149
+// Last Modified On : Tue May 16 18:35:36 2017
+// Update Count     : 150
 // 
 
@@ -22,5 +22,5 @@
 // Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
 	for ( ;; ) {										// Euclid's algorithm
@@ -33,5 +33,5 @@
 } // gcd
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
 	if ( *d == (RationalImpl){0} ) {
@@ -46,15 +46,15 @@
 // constructors
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r ) {
 	r{ (RationalImpl){0}, (RationalImpl){1} };
 } // rational
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
 	r{ n, (RationalImpl){1} };
 } // rational
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
 	RationalImpl t = simplify( &n, &d );				// simplify
@@ -66,15 +66,15 @@
 // getter for numerator/denominator
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl numerator( Rational(RationalImpl) r ) {
 	return r.numerator;
 } // numerator
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl denominator( Rational(RationalImpl) r ) {
 	return r.denominator;
 } // denominator
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
 	return *dest = src.[ numerator, denominator ];
@@ -83,5 +83,5 @@
 // setter for numerator/denominator
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
 	RationalImpl prev = r.numerator;
@@ -92,5 +92,5 @@
 } // numerator
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
 	RationalImpl prev = r.denominator;
@@ -104,30 +104,30 @@
 // comparison
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return l.numerator * r.denominator == l.denominator * r.numerator;
 } // ?==?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return ! ( l == r );
 } // ?!=?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return l.numerator * r.denominator < l.denominator * r.numerator;
 } // ?<?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return l.numerator * r.denominator <= l.denominator * r.numerator;
 } // ?<=?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return ! ( l <= r );
 } // ?>?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	return ! ( l < r );
@@ -137,5 +137,5 @@
 // arithmetic
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
 	Rational(RationalImpl) t = { r.numerator, r.denominator };
@@ -143,5 +143,5 @@
 } // +?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
 	Rational(RationalImpl) t = { -r.numerator, r.denominator };
@@ -149,5 +149,5 @@
 } // -?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	if ( l.denominator == r.denominator ) {				// special case
@@ -160,5 +160,5 @@
 } // ?+?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	if ( l.denominator == r.denominator ) {				// special case
@@ -171,5 +171,5 @@
 } // ?-?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
@@ -177,5 +177,5 @@
 } // ?*?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
 	if ( r.numerator < (RationalImpl){0} ) {
@@ -190,5 +190,5 @@
 // conversion
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
 double widen( Rational(RationalImpl) r ) {
  	return convert( r.numerator ) / convert( r.denominator );
@@ -196,5 +196,5 @@
 
 // http://www.ics.uci.edu/~eppstein/numth/frap.c
-forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
 Rational(RationalImpl) narrow( double f, RationalImpl md ) {
 	if ( md <= (RationalImpl){1} ) {					// maximum fractional digits too small?
@@ -227,5 +227,5 @@
 // I/O
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
 istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
@@ -238,5 +238,5 @@
 } // ?|?
 
-forall ( otype RationalImpl | arithmetic( RationalImpl ) )
+forall( otype RationalImpl | arithmetic( RationalImpl ) )
 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
Index: src/libcfa/stdlib
===================================================================
--- src/libcfa/stdlib	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/libcfa/stdlib	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,9 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jun  2 15:51:03 2017
-// Update Count     : 218
-//
-
-#ifndef STDLIB_H
-#define STDLIB_H
+// Last Modified On : Fri Jul  7 09:34:49 2017
+// Update Count     : 219
+//
+
+#pragma once
 
 //---------------------------------------
@@ -232,6 +231,4 @@
 void swap( T * t1, T * t2 );
 
-#endif // STDLIB_H
-
 // Local Variables: //
 // mode: c //
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/main.cc	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,43 +10,52 @@
 // Author           : Richard C. Bilson
 // Created On       : Fri May 15 23:12:02 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun 29 12:46:50 2017
-// Update Count     : 441
+// Last Modified By : Andrew Beach
+// Last Modified On : Fri Jul  7 11:13:00 2017
+// Update Count     : 442
 //
 
-#include <iostream>
-#include <fstream>
-#include <signal.h>										// signal
-#include <getopt.h>										// getopt
-#include <execinfo.h>									// backtrace, backtrace_symbols
-#include <cxxabi.h>										// __cxa_demangle
-#include <cstring>										// index
-
-using namespace std;
-
-#include "Parser/ParserTypes.h"
-#include "Parser/TypedefTable.h"
-#include "GenPoly/Lvalue.h"
-#include "GenPoly/Specialize.h"
-#include "GenPoly/Box.h"
-#include "GenPoly/CopyParams.h"
-#include "GenPoly/InstantiateGeneric.h"
-#include "Concurrency/Keywords.h"
-#include "CodeGen/Generate.h"
-#include "CodeGen/FixNames.h"
-#include "CodeGen/FixMain.h"
-#include "CodeTools/DeclStats.h"
-#include "CodeTools/TrackLoc.h"
-#include "ControlStruct/Mutate.h"
-#include "ControlStruct/ExceptTranslate.h"
-#include "SymTab/Validate.h"
-#include "ResolvExpr/AlternativePrinter.h"
-#include "ResolvExpr/Resolver.h"
-#include "MakeLibCfa.h"
-#include "InitTweak/GenInit.h"
-#include "InitTweak/FixInit.h"
-#include "Common/UnimplementedError.h"
-#include "../config.h"
-#include "Tuples/Tuples.h"
+#include <cassert>                          // for assertf
+#include <cxxabi.h>                         // for __cxa_demangle
+#include <execinfo.h>                       // for backtrace, backtrace_symbols
+#include <getopt.h>                         // for no_argument, optind, geto...
+#include <signal.h>                         // for signal, SIGABRT, SIGSEGV
+#include <cstdio>                           // for fopen, FILE, fclose, stdin
+#include <cstdlib>                          // for exit, free, abort, EXIT_F...
+#include <cstring>                          // for index
+#include <fstream>                          // for ofstream
+#include <iostream>                         // for operator<<, basic_ostream
+#include <iterator>                         // for back_inserter
+#include <list>                             // for list
+#include <string>                           // for operator<<, allocator
+
+#include "../config.h"                      // for CFA_LIBDIR
+#include "CodeGen/FixMain.h"                // for FixMain
+#include "CodeGen/FixNames.h"               // for fixNames
+#include "CodeGen/Generate.h"               // for generate
+#include "CodeTools/DeclStats.h"            // for printDeclStats
+#include "CodeTools/TrackLoc.h"             // for fillLocations
+#include "Common/CompilerError.h"           // for CompilerError
+#include "Common/SemanticError.h"           // for SemanticError
+#include "Common/UnimplementedError.h"      // for UnimplementedError
+#include "Common/utility.h"                 // for deleteAll, filter, printAll
+#include "ControlStruct/ExceptTranslate.h"  // for translateEHM
+#include "ControlStruct/Mutate.h"           // for mutate
+#include "GenPoly/Box.h"                    // for box
+#include "GenPoly/CopyParams.h"             // for copyParams
+#include "GenPoly/InstantiateGeneric.h"     // for instantiateGeneric
+#include "GenPoly/Lvalue.h"                 // for convertLvalue
+#include "GenPoly/Specialize.h"             // for convertSpecializations
+#include "InitTweak/FixInit.h"              // for fix
+#include "InitTweak/GenInit.h"              // for genInit
+#include "MakeLibCfa.h"                     // for makeLibCfa
+#include "Parser/LinkageSpec.h"             // for Spec, Cforall, Intrinsic
+#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
+#include "Parser/TypedefTable.h"            // for TypedefTable
+#include "ResolvExpr/AlternativePrinter.h"  // for AlternativePrinter
+#include "ResolvExpr/Resolver.h"            // for resolve
+#include "SymTab/Validate.h"                // for validate
+#include "SynTree/Declaration.h"            // for Declaration
+#include "SynTree/Visitor.h"                // for acceptAll
+#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
 
 using namespace std;
@@ -206,5 +215,5 @@
 				FILE * builtins = fopen( libcfap | treep ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
 				assertf( builtins, "cannot open builtins.cf\n" );
-				parse( builtins, LinkageSpec::Builtin );
+				parse( builtins, LinkageSpec::BuiltinCFA );
 			} // if
 		} // if
Index: src/prelude/Makefile.in
===================================================================
--- src/prelude/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/prelude/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -294,7 +294,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/prelude/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/prelude/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/prelude/Makefile
+	  $(AUTOMAKE) --foreign src/prelude/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/tests/.expect/32/math.txt
===================================================================
--- src/tests/.expect/32/math.txt	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/.expect/32/math.txt	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -22,5 +22,5 @@
 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
-asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
+asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
Index: src/tests/.expect/concurrent/preempt.txt
===================================================================
--- src/tests/.expect/concurrent/preempt.txt	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
+++ src/tests/.expect/concurrent/preempt.txt	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -0,0 +1,10 @@
+100
+200
+300
+400
+500
+600
+700
+800
+900
+1000
Index: src/tests/.expect/concurrent/sched-int-disjoint.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int-disjoint.txt	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/.expect/concurrent/sched-int-disjoint.txt	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -9,93 +9,3 @@
 9000
 10000
-11000
-12000
-13000
-14000
-15000
-16000
-17000
-18000
-19000
-20000
-21000
-22000
-23000
-24000
-25000
-26000
-27000
-28000
-29000
-30000
-31000
-32000
-33000
-34000
-35000
-36000
-37000
-38000
-39000
-40000
-41000
-42000
-43000
-44000
-45000
-46000
-47000
-48000
-49000
-50000
-51000
-52000
-53000
-54000
-55000
-56000
-57000
-58000
-59000
-60000
-61000
-62000
-63000
-64000
-65000
-66000
-67000
-68000
-69000
-70000
-71000
-72000
-73000
-74000
-75000
-76000
-77000
-78000
-79000
-80000
-81000
-82000
-83000
-84000
-85000
-86000
-87000
-88000
-89000
-90000
-91000
-92000
-93000
-94000
-95000
-96000
-97000
-98000
-99000
-100000
 All waiter done
Index: src/tests/.expect/io.txt
===================================================================
--- src/tests/.expect/io.txt	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/.expect/io.txt	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -4,11 +4,11 @@
 123
 
-opening delimiters 
+opening delimiters
 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
 
-closing delimiters 
-1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x 
+closing delimiters
+1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
 
-opening/closing delimiters 
+opening/closing delimiters
 x`1`x'2'x"3"x:4:x 5 x	6	x
 7
@@ -19,12 +19,12 @@
 x
 10
-x 
+x
 
-override opening/closing delimiters 
+override opening/closing delimiters
 x ( 1 ) x 2 , x 3 :x: 4
 
-input bacis types 
+input bacis types
 
-output basic types 
+output basic types
 A 
 1 2 3 4 5 6 7 8
@@ -32,32 +32,38 @@
 1.1+2.3i 1.1-2.3i 1.1-2.3i
 
-tuples 
-1, 2, 3 3, 4, 5
+tuples
+1, 2, 3 4, 5, 6
 
-toggle separator 
+toggle separator
 1.11.21.3
 1.1+2.3i1.1-2.3i1.1-2.3i
- abcxyz 
-abcxyz 
+1.1+2.3i 1.1-2.3i1.1-2.3i
+1.1+2.3i 1.1-2.3i 1.1-2.3i
+1.1+2.3i1.1-2.3i 1.1-2.3i
+abcxyz
+abcxyz
 
-change separator 
-from "  "to " , $"
+change separator
+from " " to ", $"
 1.1, $1.2, $1.3
 1.1+2.3i, $1.1-2.3i, $1.1-2.3i
-abc, $xyz, $
-1, 2, 3, $3, 4, 5
+abc, $xyz
+1, 2, 3, $4, 5, 6
 
-from ", $"to " "
+from ", $" to " "
 1.1 1.2 1.3
 1.1+2.3i 1.1-2.3i 1.1-2.3i
-abc xyz 
-1, 2, 3 3, 4, 5
+abc xyz
+1, 2, 3 4, 5, 6
 
- 1 2 3 
+check sepOn/sepOff
+1 2 3
 12 3
- 1 2 3
 1 2 3
- 1 2 3
+1 2 3
 
+1 2 3
+
+check enable/disable
 123
 1 23
@@ -65,14 +71,14 @@
 123
 1 2 3
-123 
+123
 1 2 3
 
-1 2 3 3 4 5 " "
-1, 2, 3 3, 4, 5 ", "
-1, 2, 3 3, 4, 5
+1 2 3 4 5 6 " "
+1, 2, 3 4, 5, 6 " "
+1, 2, 3 4, 5, 6
 
 3, 4, a, 7.2
 3, 4, a, 7.2
 3 4 a 7.2
- 3 4 a 7.234a7.23 4 a 7.2
+3 4 a 7.234a7.23 4 a 7.2
 3-4-a-7.2^3^4^3-4-a-7.2
Index: src/tests/Makefile.am
===================================================================
--- src/tests/Makefile.am	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/Makefile.am	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -29,6 +29,17 @@
 
 # applies to both programs
-EXTRA_FLAGS =
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
+DEBUG_FLAGS =
+
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@
+if !BUILD_DEBUG
+BUILD_FLAGS += -nodebug
+else
+if !BUILD_RELEASE
+BUILD_FLAGS += -debug
+else
+BUILD_FLAGS += ${DEBUG_FLAGS}
+endif
+endif
+
 TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
 AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
Index: src/tests/Makefile.in
===================================================================
--- src/tests/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -92,4 +92,7 @@
 host_triplet = @host@
 @BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor
+@BUILD_DEBUG_FALSE@am__append_2 = -nodebug
+@BUILD_DEBUG_TRUE@@BUILD_RELEASE_FALSE@am__append_3 = -debug
+@BUILD_DEBUG_TRUE@@BUILD_RELEASE_TRUE@am__append_4 = ${DEBUG_FLAGS}
 EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
 	avl_test$(EXEEXT)
@@ -320,6 +323,7 @@
 
 # applies to both programs
-EXTRA_FLAGS = 
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
+DEBUG_FLAGS = 
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ \
+	$(am__append_2) $(am__append_3) $(am__append_4)
 TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
 AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
@@ -343,7 +347,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tests/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/tests/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/tests/Makefile
+	  $(AUTOMAKE) --foreign src/tests/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
Index: src/tests/io.c
===================================================================
--- src/tests/io.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/io.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Mar  2 16:56:02 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jul  2 09:40:58 2017
-// Update Count     : 68
+// Last Modified On : Thu Jul  6 23:26:12 2017
+// Update Count     : 78
 // 
 
@@ -104,5 +104,5 @@
 
 	sout | "tuples" | endl;
-	[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
+	[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
 	sout | t1 | t2 | endl;								// print tuple
 	sout | endl;
@@ -110,13 +110,16 @@
 	sout | "toggle separator" | endl;
 	sout | f | "" | d | "" | ld | endl					// floating point without separator
-		| sepDisable | fc | dc | ldc | sepEnable | endl	// complex without separator
-		| sepOn | s1 | sepOff | s2 | endl				// local separator removal
-		| s1 | "" | s2 | endl;							// C string without separator
+		| sepDisable | fc | dc | ldc | endl				// complex without separator
+		| fc | sepOn | dc | ldc | endl					// local separator add
+		| sepEnable | fc | dc | ldc | endl				// complex with separator
+		| fc | sepOff | dc | ldc | endl					// local separator removal
+		| s1 | sepOff | s2 | endl						// local separator removal
+		| s1 | "" | s2 | endl;							// local separator removal
 	sout | endl;
 
 	sout | "change separator" | endl;
-	sout | "from \" " | sepGet( sout ) | "\"";
+	sout | "from \"" | sep | "\"";
 	sepSet( sout, ", $" );								// change separator, maximum of 15 characters
-	sout | "to \" " | sepGet( sout ) | "\"" | endl;
+	sout | " to \"" | sep | "\"" | endl;
 	sout | f | d | ld | endl
 		| fc | dc | ldc | endl
@@ -124,7 +127,7 @@
 		| t1 | t2 | endl;								// print tuple
 	sout | endl;
-	sout | "from \"" | sepGet( sout ) | "\"";
+	sout | "from \"" | sep | "\" ";
 	sepSet( sout, " " );								// restore separator
-	sout | "to \"" | sepGet( sout ) | "\"" | endl;
+	sout | "to \"" | sep | "\"" | endl;
 	sout | f | d | ld | endl
 		| fc | dc | ldc | endl
@@ -133,11 +136,13 @@
 	sout | endl;
 
-	sout | sepOn | 1 | 2 | 3 | sepOn | endl;			// separator at start/end of line
+	sout | "check sepOn/sepOff" | endl;
+	sout | sepOn | 1 | 2 | 3 | sepOn | endl;			// no separator at start/end of line
 	sout | 1 | sepOff | 2 | 3 | endl;					// locally turn off implicit separator
-	sout | sepOn | 1 | 2 | 3 | sepOn | sepOff | endl;	// separator at start of line
-	sout | 1 | 2 | 3 | endl | sepOn;					// separator at start of next line
+	sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line
+	sout | 1 | 2 | 3 | "\n\n" | sepOn;					// no separator at start of next line
 	sout | 1 | 2 | 3 | endl;
 	sout | endl;
 
+	sout | "check enable/disable" | endl;
 	sout | sepDisable | 1 | 2 | 3 | endl;				// globally turn off implicit separation
 	sout | 1 | sepOn | 2 | 3 | endl;					// locally turn on implicit separator
@@ -149,8 +154,11 @@
 	sout | endl;
 
+//	sout | fmt( d, "%8.3f" ) || endl;
+//	sout | endl;
+
 	sepSetTuple( sout, " " );							// set tuple separator from ", " to " "
-	sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
+	sout | t1 | t2 | " \"" | sep | "\"" | endl;
 	sepSetTuple( sout, ", " );							// reset tuple separator to ", "
-	sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
+	sout | t1 | t2 | " \"" | sep | "\"" | endl;
 	sout | t1 | t2 | endl;								// print tuple
 	sout | endl;
Index: src/tests/preempt.c
===================================================================
--- src/tests/preempt.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
+++ src/tests/preempt.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -0,0 +1,42 @@
+#include <kernel>
+#include <thread>
+
+#ifndef PREEMPTION_RATE
+#define PREEMPTION_RATE 10_000ul
+#endif
+
+unsigned int default_preemption() {
+	return PREEMPTION_RATE;
+}
+
+static volatile int counter = 0;
+
+thread worker_t {
+	int value;
+};
+
+void ?{}( worker_t * this, int value ) {
+	this->value = value;
+}
+
+void main(worker_t * this) {
+	while(counter < 1000) {
+		if( (counter % 7) == this->value ) {
+			int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
+			if( (next % 100) == 0 ) printf("%d\n", next);
+		}
+	}
+}
+
+int main(int argc, char* argv[]) {
+	processor p;
+	{
+		worker_t w0 = 0;
+		worker_t w1 = 1;
+		worker_t w2 = 2;
+		worker_t w3 = 3;
+		worker_t w4 = 4;
+		worker_t w5 = 5;
+		worker_t w6 = 6;
+	}
+}
Index: src/tests/preempt_longrun/Makefile.am
===================================================================
--- src/tests/preempt_longrun/Makefile.am	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/Makefile.am	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,12 +10,12 @@
 ## Author           : Thierry Delisle
 ## Created On       : Fri Jun 16 10:57:34 2017
-## Last Modified By : 
-## Last Modified On : 
+## Last Modified By :
+## Last Modified On :
 ## Update Count     : 0
 ###############################################################################
 
 repeats=10
-max_time=30
-preempt=10_000ul
+max_time=600
+preempt=1_000ul
 
 REPEAT = ${abs_top_srcdir}/tools/repeat -s
@@ -25,5 +25,5 @@
 CC = @CFA_BINDIR@/@CFA_NAME@
 
-TESTS = barge block create disjoint processor stack wait yield
+TESTS = barge block create disjoint enter enter3 processor stack wait yield
 
 .INTERMEDIATE: ${TESTS}
Index: src/tests/preempt_longrun/Makefile.in
===================================================================
--- src/tests/preempt_longrun/Makefile.in	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/Makefile.in	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -449,9 +449,9 @@
 top_srcdir = @top_srcdir@
 repeats = 10
-max_time = 30
-preempt = 10_000ul
+max_time = 600
+preempt = 1_000ul
 REPEAT = ${abs_top_srcdir}/tools/repeat -s
 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -debug -O2 -DPREEMPTION_RATE=${preempt}
-TESTS = barge block create disjoint processor stack wait yield
+TESTS = barge block create disjoint enter enter3 processor stack wait yield
 all: all-am
 
@@ -467,7 +467,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tests/preempt_longrun/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/tests/preempt_longrun/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/tests/preempt_longrun/Makefile
+	  $(AUTOMAKE) --foreign src/tests/preempt_longrun/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -663,4 +663,18 @@
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+enter.log: enter
+	@p='enter'; \
+	b='enter'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+enter3.log: enter3
+	@p='enter3'; \
+	b='enter3'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 processor.log: processor
 	@p='processor'; \
Index: src/tests/preempt_longrun/create.c
===================================================================
--- src/tests/preempt_longrun/create.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/create.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,11 +10,12 @@
 }
 
-thread Worker {};
+thread worker_t {};
 
-void main(Worker * this) {}
+void main(worker_t * this) {}
 
 int main(int argc, char* argv[]) {
-	for(int i = 0; i < 100_000ul; i++) {
-		Worker w;
+	processor p;
+	for(int i = 0; i < 10_000ul; i++) {
+		worker_t w[7];
 	}
 }
Index: src/tests/preempt_longrun/enter.c
===================================================================
--- src/tests/preempt_longrun/enter.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
+++ src/tests/preempt_longrun/enter.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -0,0 +1,40 @@
+#include <kernel>
+#include <monitor>
+#include <thread>
+
+#undef N
+static const unsigned long N  = 70_000ul;
+
+#ifndef PREEMPTION_RATE
+#define PREEMPTION_RATE 10_000ul
+#endif
+
+unsigned int default_preemption() {
+	return PREEMPTION_RATE;
+}
+
+monitor mon_t {};
+
+mon_t mon;
+
+void foo( mon_t * mutex this ) {}
+
+thread worker_t {};
+
+void main( worker_t * this ) {
+	for( unsigned long i = 0; i < N; i++ ) {
+		foo( &mon );
+	}
+}
+
+extern "C" {
+static worker_t * workers;
+}
+
+int main(int argc, char * argv[] ) {
+	processor p;
+	{
+		worker_t w[7];
+		workers = w;
+	}
+}
Index: src/tests/preempt_longrun/enter3.c
===================================================================
--- src/tests/preempt_longrun/enter3.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
+++ src/tests/preempt_longrun/enter3.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -0,0 +1,40 @@
+#include <kernel>
+#include <monitor>
+#include <thread>
+
+#undef N
+static const unsigned long N  = 50_000ul;
+
+#ifndef PREEMPTION_RATE
+#define PREEMPTION_RATE 10_000ul
+#endif
+
+unsigned int default_preemption() {
+	return PREEMPTION_RATE;
+}
+
+monitor mon_t {};
+
+mon_t mon1, mon2, mon3;
+
+void foo( mon_t * mutex a, mon_t * mutex b, mon_t * mutex c ) {}
+
+thread worker_t {};
+
+void main( worker_t * this ) {
+	for( unsigned long i = 0; i < N; i++ ) {
+		foo( &mon1, &mon2, &mon3 );
+	}
+}
+
+extern "C" {
+static worker_t * workers;
+}
+
+int main(int argc, char * argv[] ) {
+	processor p;
+	{
+		worker_t w[7];
+		workers = w;
+	}
+}
Index: src/tests/preempt_longrun/processor.c
===================================================================
--- src/tests/preempt_longrun/processor.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/processor.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,10 @@
 }
 
-thread Worker {};
+thread worker_t {};
 
-void main(Worker * this) {}
+void main(worker_t * this) {}
 
 int main(int argc, char* argv[]) {
-	for(int i = 0; i < 100_000ul; i++) {
+	for(int i = 0; i < 10_000ul; i++) {
 		processor p;
 	}
Index: src/tests/preempt_longrun/stack.c
===================================================================
--- src/tests/preempt_longrun/stack.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/stack.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -12,15 +12,15 @@
 }
 
-thread Worker {};
+thread worker_t {};
 
-void main(Worker * this) {
+void main(worker_t * this) {
 	volatile long p = 5_021_609ul;
 	volatile long a = 326_417ul;
 	volatile long n = 1l;
-	for (volatile long i = 0; i < p; i++) { 
-		n *= a; 
-		n %= p; 
+	for (volatile long i = 0; i < p; i++) {
+		n *= a;
+		n %= p;
 	}
-		
+
 	if( n != a ) {
 		abort();
@@ -28,8 +28,13 @@
 }
 
+extern "C" {
+static worker_t * workers;
+}
+
 int main(int argc, char* argv[]) {
 	processor p;
 	{
-		Worker w[7];
+		worker_t w[7];
+		workers = w;
 	}
 }
Index: src/tests/preempt_longrun/yield.c
===================================================================
--- src/tests/preempt_longrun/yield.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/preempt_longrun/yield.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -10,10 +10,14 @@
 }
 
-thread Worker {};
+thread worker_t {};
 
-void main(Worker * this) {
-	for(int i = 0; i < 100_000ul; i++) {
+void main(worker_t * this) {
+	for(int i = 0; i < 325_000ul; i++) {
 		yield();
 	}
+}
+
+extern "C" {
+static worker_t * workers;
 }
 
@@ -21,5 +25,6 @@
 	processor p;
 	{
-		Worker w[7];
+		worker_t w[7];
+		workers = w;
 	}
 }
Index: src/tests/sched-int-block.c
===================================================================
--- src/tests/sched-int-block.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/sched-int-block.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -6,5 +6,5 @@
 
 #ifndef N
-#define N 100_000
+#define N 10_000
 #endif
 
@@ -31,5 +31,5 @@
 //------------------------------------------------------------------------------
 void wait_op( global_data_t * mutex a, global_data_t * mutex b, unsigned i ) {
-	wait( &cond, (uintptr_t)this_thread() );
+	wait( &cond, (uintptr_t)this_thread );
 
 	yield( ((unsigned)rand48()) % 10 );
@@ -40,5 +40,5 @@
 	}
 
-	a->last_thread = b->last_thread = this_thread();
+	a->last_thread = b->last_thread = this_thread;
 
 	yield( ((unsigned)rand48()) % 10 );
@@ -56,5 +56,5 @@
 	yield( ((unsigned)rand48()) % 10 );
 
-	a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread();
+	a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread;
 
 	if( !is_empty( &cond ) ) {
@@ -86,5 +86,5 @@
 //------------------------------------------------------------------------------
 void barge_op( global_data_t * mutex a ) {
-	a->last_thread = this_thread();
+	a->last_thread = this_thread;
 }
 
Index: src/tests/sched-int-disjoint.c
===================================================================
--- src/tests/sched-int-disjoint.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/sched-int-disjoint.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -5,5 +5,5 @@
 
 #ifndef N
-#define N 100_000
+#define N 10_000
 #endif
 
@@ -42,7 +42,7 @@
 
 void main( Barger * this ) {
-	while( !all_done ) { 
+	while( !all_done ) {
 		barge( &data );
-		yield(); 
+		yield();
 	}
 }
@@ -53,5 +53,5 @@
 	wait( &cond );
 	if( d->state != SIGNAL ) {
-		sout | "ERROR barging!" | endl; 
+		sout | "ERROR barging!" | endl;
 	}
 
@@ -85,5 +85,5 @@
 	bool running = data.counter < N && data.counter > 0;
 	if( data.state != SIGNAL && running ) {
-		sout | "ERROR Eager signal" | data.state | endl; 
+		sout | "ERROR Eager signal" | data.state | endl;
 	}
 }
@@ -92,7 +92,7 @@
 
 void main( Signaller * this ) {
-	while( !all_done ) { 
+	while( !all_done ) {
 		logic( &mut );
-		yield(); 
+		yield();
 	}
 }
@@ -111,4 +111,4 @@
 		sout | "All waiter done" | endl;
 		all_done = true;
-	}	
+	}
 }
Index: src/tests/sched-int-wait.c
===================================================================
--- src/tests/sched-int-wait.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/sched-int-wait.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -50,14 +50,14 @@
 		unsigned action = (unsigned)rand48() % 4;
 		switch( action ) {
-			case 0: 
+			case 0:
 				signal( &condABC, &globalA, &globalB, &globalC );
 				break;
-			case 1: 
+			case 1:
 				signal( &condAB , &globalA, &globalB );
 				break;
-			case 2: 
+			case 2:
 				signal( &condBC , &globalB, &globalC );
 				break;
-			case 3: 
+			case 3:
 				signal( &condAC , &globalA, &globalC );
 				break;
@@ -67,5 +67,5 @@
 		}
 		yield();
-	}	
+	}
 }
 
Index: src/tests/test.py
===================================================================
--- src/tests/test.py	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/test.py	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -166,5 +166,5 @@
 
 	# build, skipping to next test on error
-	make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
+	make_ret, _ = sh("""%s test=yes DEBUG_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
 
 	retcode = 0
@@ -202,5 +202,5 @@
 			error = myfile.read()
 
-		
+
 	# clean the executable
 	sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
Index: src/tests/thread.c
===================================================================
--- src/tests/thread.c	(revision 55a68c3dc9290e2bb34da101039e435d02bc9dea)
+++ src/tests/thread.c	(revision 3d4b23fa9ef416e3543e652102009137f340d4e5)
@@ -4,15 +4,9 @@
 #include <thread>
 
-// thread First;
-// void main(First* this);
+thread First  { semaphore* lock; };
+thread Second { semaphore* lock; };
 
-// thread Second;
-// void main(Second* this);
-
-thread First  { signal_once* lock; };
-thread Second { signal_once* lock; };
-
-void ?{}( First * this, signal_once* lock ) { this->lock = lock; }
-void ?{}( Second * this, signal_once* lock ) { this->lock = lock; }
+void ?{}( First * this, semaphore* lock ) { this->lock = lock; }
+void ?{}( Second * this, semaphore* lock ) { this->lock = lock; }
 
 void main(First* this) {
@@ -21,9 +15,9 @@
 		yield();
 	}
-	signal(this->lock);
+	V(this->lock);
 }
 
 void main(Second* this) {
-	wait(this->lock);
+	P(this->lock);
 	for(int i = 0; i < 10; i++) {
 		sout | "Second : Suspend No." | i + 1 | endl;
@@ -34,5 +28,5 @@
 
 int main(int argc, char* argv[]) {
-	signal_once lock;
+	semaphore lock = { 0 };
 	sout | "User main begin" | endl;
 	{
