Index: Jenkins/Distribute
===================================================================
--- Jenkins/Distribute	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
+++ Jenkins/Distribute	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -0,0 +1,125 @@
+#!groovy
+
+import groovy.transform.Field
+
+// For skipping stages
+import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
+
+//===========================================================================================================
+// Main loop of the compilation
+//===========================================================================================================
+
+node('master') {
+	// Globals
+	BuildDir  = pwd tmp: true
+	SrcDir    = pwd tmp: false
+	Settings  = null
+
+	// Local variables
+	def err = null
+	def log_needed = false
+
+	currentBuild.result = "SUCCESS"
+
+	try {
+		//Wrap build to add timestamp to command line
+		wrap([$class: 'TimestamperBuildWrapper']) {
+
+			final commit = prepare_build()
+
+			node('x64') {
+				BuildDir  = pwd tmp: true
+				SrcDir    = pwd tmp: false
+
+				Tools.Clean()
+
+				Tools.Checkout( commit )
+			}
+
+			// Update the build directories when exiting the node
+			BuildDir  = pwd tmp: true
+			SrcDir    = pwd tmp: false
+		}
+	}
+
+	//If an exception is caught we need to change the status and remember to
+	//attach the build log to the email
+	// catch (Exception caughtError) {
+		// //rethrow error later
+		// err = caughtError
+
+		// echo err.toString()
+
+		// //An error has occured, the build log is relevent
+		// log_needed = true
+
+		// //Store the result of the build log
+		// currentBuild.result = "${StageName} FAILURE".trim()
+	// }
+
+	finally {
+		// //Send email with final results if this is not a full build
+		// email(log_needed)
+
+		// echo 'Distribution Completed'
+
+		// /* Must re-throw exception to propagate error */
+		// if (err) {
+		// 	throw err
+		// }
+	}
+}
+
+//===========================================================================================================
+// Main compilation routines
+//===========================================================================================================
+
+
+//Compilation script is done here but environnement set-up and error handling is done in main loop
+// def checkout() {
+// 	build_stage('Checkout', true) {
+// 		//checkout the source code and clean the repo
+// 		final scmVars = checkout scm
+// 		Settings.GitNewRef = scmVars.GIT_COMMIT
+// 		Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT
+
+// 		echo GitLogMessage()
+// 	}
+// }
+
+//===========================================================================================================
+// Helper classes/variables/routines
+//===========================================================================================================
+def prepare_build() {
+	// prepare the properties
+	properties ([ 													\
+		buildDiscarder(logRotator(										\
+			artifactDaysToKeepStr: '',									\
+			artifactNumToKeepStr: '',									\
+			daysToKeepStr: '730',										\
+			numToKeepStr: '1000'										\
+		)),														\
+		[$class: 'ParametersDefinitionProperty', 								\
+			parameterDefinitions: [ 									\
+				[$class: 'StringParameterDefinition',						\
+					description: 'The git commit to checkout',				\
+					name: 'GitRef',									\
+					defaultValue: '',  								\
+				],												\
+			],
+		]])
+
+	// It's unfortunate but it looks like we need to checkout the entire repo just to get
+	// - the pretty git printer
+	// - Jenkins.tools
+	checkout scm
+
+	Tools = load "Jenkins/tools.groovy"
+
+	currentBuild.description = "Distributing Tarball"
+	def ref = params.GitRef ? params.GitRef : "HEAD"
+	echo "Distributing git commit ${ref}"
+
+	return params.GitRef
+}
+
Index: Jenkins/tools.groovy
===================================================================
--- Jenkins/tools.groovy	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
+++ Jenkins/tools.groovy	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -0,0 +1,110 @@
+#!groovy
+
+import groovy.transform.Field
+
+// For skipping stages
+import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
+
+// Global for the stage name
+StageName = ''
+
+// wrapper around stage declaretion to be more verbose
+// and allow showing as skipped in the UI
+def BuildStage(String name, boolean run, Closure block ) {
+	StageName = name
+	echo " -------- ${StageName} -------- "
+	if(run) {
+		stage(name, block)
+	} else {
+		stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }
+	}
+}
+
+//===========================================================================================================
+// Common compilation routines
+//===========================================================================================================
+def Clean() {
+	BuildStage('Cleanup', true) {
+		// clean the build by wipping the build directory
+		dir(BuildDir) {
+			deleteDir()
+		}
+	}
+}
+
+def Checkout(commitHash = null) {
+	BuildStage('Checkout', true) {
+		//checkout the source code and clean the repo
+		if(commitHash) {
+			final scmVars = checkout([$class: 'GitSCM', branches: [[name: commitHash ]]])
+			echo GitLogMessage(scmVars.GIT_COMMIT, scmVars.GIT_PREVIOUS_COMMIT)
+		} else {
+
+			final scmVars = checkout scm
+			echo GitLogMessage(scmVars.GIT_COMMIT, scmVars.GIT_PREVIOUS_COMMIT)
+		}
+	}
+}
+
+//===========================================================================================================
+//Routine responsible of sending the email notification once the build is completed
+//===========================================================================================================
+@NonCPS
+def SplitLines(String text) {
+	def list = []
+
+	text.eachLine {
+		list += it
+	}
+
+	return list
+}
+
+def GitLogMessage(String oldRef, String newRef) {
+	def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
+	def revList = SplitLines( revText )
+
+	def gitUpdate = ""
+	revList.each { rev ->
+		def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
+		gitUpdate = gitUpdate + "       via  ${rev} (${type})"
+	}
+
+	def rev = oldRef
+	def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
+	gitUpdate = gitUpdate + "      from  ${rev} (${type})"
+
+	def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
+
+	def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
+	gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
+	gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
+	gitDiff = gitDiff.replace('[m', '</span>')
+
+	return """
+<pre>
+The branch ${env.BRANCH_NAME} has been updated.
+${gitUpdate}
+</pre>
+
+<p>Check console output at ${env.BUILD_URL} to view the results.</p>
+
+<p>- Status --------------------------------------------------------------</p>
+
+<p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
+
+<p>- Log -----------------------------------------------------------------</p>
+
+<pre>
+${gitLog}
+</pre>
+
+<p>-----------------------------------------------------------------------</p>
+<pre>
+Summary of changes:
+${gitDiff}
+</pre>
+"""
+}
+
+return this;
Index: Jenkinsfile
===================================================================
--- Jenkinsfile	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ Jenkinsfile	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -2,7 +2,4 @@
 
 import groovy.transform.Field
-
-// For skipping stages
-import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
 
 //===========================================================================================================
@@ -15,5 +12,5 @@
 	SrcDir    = pwd tmp: false
 	Settings  = null
-	StageName = ''
+	Tools     = null
 
 	// Local variables
@@ -66,5 +63,5 @@
 
 		//Store the result of the build log
-		currentBuild.result = "${StageName} FAILURE".trim()
+		currentBuild.result = "${tools.StageName} FAILURE".trim()
 	}
 
@@ -85,5 +82,5 @@
 //===========================================================================================================
 def clean() {
-	build_stage('Cleanup', true) {
+	Tools.BuildStage('Cleanup', true) {
 		// clean the build by wipping the build directory
 		dir(BuildDir) {
@@ -95,5 +92,5 @@
 //Compilation script is done here but environnement set-up and error handling is done in main loop
 def checkout() {
-	build_stage('Checkout', true) {
+	Tools.BuildStage('Checkout', true) {
 		//checkout the source code and clean the repo
 		final scmVars = checkout scm
@@ -108,5 +105,5 @@
 	debug = true
 	release = Settings.RunAllTests || Settings.RunBenchmark
-	build_stage('Build : configure', true) {
+	Tools.BuildStage('Build : configure', true) {
 		// Configure must be run inside the tree
 		dir (SrcDir) {
@@ -136,5 +133,5 @@
 	}
 
-	build_stage('Build : cfa-cpp', true) {
+	Tools.BuildStage('Build : cfa-cpp', true) {
 		// Build outside of the src tree to ease cleaning
 		dir (BuildDir) {
@@ -147,5 +144,5 @@
 	}
 
-	build_stage('Build : libcfa(debug)', debug) {
+	Tools.BuildStage('Build : libcfa(debug)', debug) {
 		// Build outside of the src tree to ease cleaning
 		dir (BuildDir) {
@@ -154,5 +151,5 @@
 	}
 
-	build_stage('Build : libcfa(nodebug)', release) {
+	Tools.BuildStage('Build : libcfa(nodebug)', release) {
 		// Build outside of the src tree to ease cleaning
 		dir (BuildDir) {
@@ -161,5 +158,5 @@
 	}
 
-	build_stage('Build : install', true) {
+	Tools.BuildStage('Build : install', true) {
 		// Build outside of the src tree to ease cleaning
 		dir (BuildDir) {
@@ -171,5 +168,5 @@
 def test() {
 	try {
-		build_stage('Test: short', !Settings.RunAllTests) {
+		Tools.BuildStage('Test: short', !Settings.RunAllTests) {
 			dir (BuildDir) {
 				//Run the tests from the tests directory
@@ -178,5 +175,5 @@
 		}
 
-		build_stage('Test: full', Settings.RunAllTests) {
+		Tools.BuildStage('Test: full', Settings.RunAllTests) {
 			dir (BuildDir) {
 					//Run the tests from the tests directory
@@ -196,5 +193,5 @@
 
 def benchmark() {
-	build_stage('Benchmark', Settings.RunBenchmark) {
+	Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
 		dir (BuildDir) {
 			//Append bench results
@@ -205,5 +202,5 @@
 
 def build_doc() {
-	build_stage('Documentation', Settings.BuildDocumentation) {
+	Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
 		dir ('doc/user') {
 			make_doc()
@@ -217,5 +214,5 @@
 
 def publish() {
-	build_stage('Publish', true) {
+	Tools.BuildStage('Publish', true) {
 
 		if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
@@ -506,6 +503,10 @@
 		]])
 
-	// It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer
+	// It's unfortunate but it looks like we need to checkout the entire repo just to get
+	// - the pretty git printer
+	// - Jenkins.tools
 	checkout scm
+
+	Tools = load "Jenkins/tools.groovy"
 
 	final settings = new BuildSettings(params, env.BRANCH_NAME)
@@ -515,14 +516,4 @@
 
 	return settings
-}
-
-def build_stage(String name, boolean run, Closure block ) {
-	StageName = name
-	echo " -------- ${StageName} -------- "
-	if(run) {
-		stage(name, block)
-	} else {
-		stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }
-	}
 }
 
Index: example/io/simple/server.cfa
===================================================================
--- example/io/simple/server.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ example/io/simple/server.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -13,4 +13,5 @@
 #include <time.hfa>
 #include <thread.hfa>
+#include <concurrency/iofwd.hfa>
 
 //----------
@@ -21,6 +22,6 @@
 }
 
-void message( Printer & mutex, char * msg, size_t len ) {
-	fprintf(stderr, "'%.*s'", len, msg);
+void message( Printer & mutex, char * _msg, size_t len ) {
+	fprintf(stderr, "'%.*s'", len, _msg);
 }
 
@@ -29,6 +30,6 @@
 }
 
-void error( Printer & mutex, const char * msg, int error) {
-	fprintf(stderr, "%s - %s\n", msg, strerror(error));
+void error( Printer & mutex, const char * _msg, int error) {
+	fprintf(stderr, "%s - %s\n", _msg, strerror(error));
 }
 
@@ -49,9 +50,4 @@
 	}
 }
-
-//----------
-extern ssize_t cfa_recvmsg(int sockfd, struct msghdr *msg, int flags);
-extern int cfa_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
-extern int cfa_close(int fd);
 
 //----------
@@ -88,5 +84,5 @@
 	struct sockaddr_in cli_addr;
      	__socklen_t clilen = sizeof(cli_addr);
-	int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0);
+	int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0, 0, -1`s, 0p, 0p);
      	if (newsock < 0) {
 		error( printer, "accept", -newsock);
@@ -97,5 +93,5 @@
 
 	while(1) {
-		int res = cfa_recvmsg(newsock, &msg, 0);
+		int res = cfa_recvmsg(newsock, &msg, 0, 0, -1`s, 0p, 0p);
 		if(res == 0) break;
 		if(res < 0) {
@@ -107,5 +103,5 @@
 	}
 
-	ret = cfa_close(newsock);
+	ret = cfa_close(newsock, 0, -1`s, 0p, 0p);
       if(ret < 0) {
             error( printer, "close new", -ret);
@@ -113,5 +109,5 @@
       }
 
-	ret = cfa_close(sock);
+	ret = cfa_close(sock, 0, -1`s, 0p, 0p);
       if(ret < 0) {
             error( printer, "close old", -ret);
Index: libcfa/src/bits/containers.hfa
===================================================================
--- libcfa/src/bits/containers.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/bits/containers.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -17,5 +17,5 @@
 #include "bits/align.hfa"
 #include "bits/defs.hfa"
-
+#include <stdio.h>
 //-----------------------------------------------------------------------------
 // Array
@@ -146,23 +146,23 @@
 	static inline forall( dtype T | is_node(T) ) {
 		void ?{}( __queue(T) & this ) with( this ) {
-			head{ 1p };
-			tail{ &head };
-			verify(*tail == 1p);
+			(this.head){ 1p };
+			(this.tail){ &this.head };
+			verify(*this.tail == 1p);
 		}
 
 		void append( __queue(T) & this, T * val ) with( this ) {
-			verify(tail != 0p);
-			verify(*tail == 1p);
-			*tail = val;
-			tail = &get_next( *val );
-			*tail = 1p;
+			verify(this.tail != 0p);
+			verify(*this.tail == 1p);
+			*this.tail = val;
+			this.tail = &get_next( *val );
+			*this.tail = 1p;
 		}
 
 		T * peek( __queue(T) & this ) {
 			verify(*this.tail == 1p);
-			T * head = this.head;
-			if( head != 1p ) {
+			T * front = this.head;
+			if( front != 1p ) {
 				verify(*this.tail == 1p);
-				return head;
+				return front;
 			}
 			verify(*this.tail == 1p);
@@ -172,14 +172,14 @@
 		T * pop_head( __queue(T) & this ) {
 			verify(*this.tail == 1p);
-			T * head = this.head;
-			if( head != 1p ) {
-				this.head = get_next( *head );
-				if( get_next( *head ) == 1p ) {
+			T * _head = this.head;
+			if( _head != 1p ) {
+				this.head = get_next( *_head );
+				if( get_next( *_head ) == 1p ) {
 					this.tail = &this.head;
 				}
-				get_next( *head ) = 0p;
+				get_next( *_head ) = 0p;
 				verify(*this.tail == 1p);
-				verify( get_next(*head) == 0p );
-				return head;
+				verify( get_next(*_head) == 0p );
+				return _head;
 			}
 			verify(*this.tail == 1p);
@@ -193,12 +193,12 @@
 			(*it) = get_next( *val );
 
-			if( tail == &get_next( *val ) ) {
-				tail = it;
+			if( this.tail == &get_next( *val ) ) {
+				this.tail = it;
 			}
 
 			get_next( *val ) = 0p;
 
-			verify( (head == 1p) == (&head == tail) );
-			verify( *tail == 1p );
+			verify( (this.head == 1p) == (&this.head == this.tail) );
+			verify( *this.tail == 1p );
 			return val;
 		}
@@ -239,5 +239,5 @@
 	forall(dtype T )
 	static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
-		this.head{ 0p };
+		(this.head){ 0p };
 		this.__get = __get;
 	}
@@ -248,11 +248,11 @@
 		void push_front( __dllist(T) & this, T & node ) with( this ) {
 			verify(__get);
-			if ( head ) {
-				__get( node ).next = head;
-				__get( node ).prev = __get( *head ).prev;
+			if ( this.head ) {
+				__get( node ).next = this.head;
+				__get( node ).prev = __get( *this.head ).prev;
 				// inserted node must be consistent before it is seen
 				// prevent code movement across barrier
 				asm( "" : : : "memory" );
-				__get( *head ).prev = &node;
+				__get( *this.head ).prev = &node;
 				T & _prev = *__get( node ).prev;
 				__get( _prev ).next = &node;
@@ -264,14 +264,14 @@
 			// prevent code movement across barrier
 			asm( "" : : : "memory" );
-			head = &node;
+			this.head = &node;
 		}
 
 		void remove( __dllist(T) & this, T & node ) with( this ) {
 			verify(__get);
-			if ( &node == head ) {
-				if ( __get( *head ).next == head ) {
-					head = 0p;
+			if ( &node == this.head ) {
+				if ( __get( *this.head ).next == this.head ) {
+					this.head = 0p;
 				} else {
-					head = __get( *head ).next;
+					this.head = __get( *this.head ).next;
 				}
 			}
Index: libcfa/src/bits/multi_list.cfa
===================================================================
--- libcfa/src/bits/multi_list.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
+++ libcfa/src/bits/multi_list.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -0,0 +1,101 @@
+#include <fstream.hfa>
+#include <stdlib.hfa>
+#include "sequence.hfa"
+#include "queue.hfa"
+#include "stack.hfa"
+
+struct Task;											// node type
+
+struct TaskDL {
+	inline Seqable;
+	Task & node;
+};
+void ?{}( TaskDL & this, Task & task ) with( this ) {
+	((Seqable &)this){};
+	&node = &task;										// pointer to containing node
+}
+Task & task( TaskDL & this ) with( this ) {				// getter routine for containing node
+	return node;
+}
+
+struct TaskSL {
+	inline Colable;
+	Task & node;
+};
+void ?{}( TaskSL & this, Task & task ) with( this ) {
+	((Colable &)this){};
+	&node = &task;										// pointer to containing node
+}
+Task & task( TaskSL & this ) with( this ) {				// getter routine for containing node
+	return node;
+}
+
+struct Task {
+	TaskDL clusterRef;									// list of tasks on cluster
+	TaskDL readyRef;									// list of tasks on ready queue
+	TaskSL mutexRef;									// list of tasks on mutex queue
+	int id;
+};
+void ?{}( Task & this, int id ) with( this ) {
+	((TaskDL &)clusterRef){ this };
+	((TaskDL &)readyRef){ this };
+	((TaskSL &)mutexRef){ this };
+	this.id = id;
+}
+
+int main() {
+	Sequence(TaskDL) clustList, readyList;				// task lists
+	Queue(TaskSL) mutexList;
+	enum { Lnth = 10 };
+
+	for ( id; Lnth ) {
+		Task & task = *new( id );						// create task node
+		addHead( clustList, task.clusterRef );			// insert on lists in opposite directions
+		addTail( readyList, task.readyRef );
+		addHead( mutexList, task.mutexRef );
+	}
+
+	SeqIter(TaskDL) sqiter;
+	TaskDL & dl;
+	TaskSL & sl;
+
+	sout | nlOff;
+	for ( over( sqiter, clustList ); sqiter >> dl; ) {	// print lists
+		Task & tmp = task( dl ); sout | tmp.id;
+		// sout | task( dl ).id;
+	}
+	sout | nl;
+	for ( over( sqiter, readyList ); sqiter >> dl; ) {
+		Task & tmp = task( dl ); sout | tmp.id;
+		// sout | task( dl ).id;
+	}
+	sout | nl;
+	for ( QueueIter(TaskSL) qiter = { mutexList }; qiter >> sl; ) {	// print lists
+		Task & tmp = task( sl ); sout | tmp.id;
+		// sout | task( sl ).id;
+	}
+	sout | nl;
+	for ( Lnth ) {										// remove nodes from clustList. mutexList
+		dropHead( clustList );
+		drop( mutexList );
+	}
+	// Simultaneous deletion only safe if all nodes are traversed in same direction.
+	for ( Lnth ) {										// remove nodes from readyList and safe to delete nodes
+		delete( &task( dropHead( readyList ) ) );
+	}
+
+	// Re-purpose Seqable as Colable
+	Stack(TaskDL) mutexStack;
+	for ( id; Lnth ) {
+		Task & task = *new( id );						// create task node
+		push( mutexStack, task.clusterRef );			// insert on lists in opposite directions
+	}
+	for ( StackIter(TaskDL) stiter = { mutexStack }; stiter >> dl; ) {
+		Task & tmp = task( dl ); sout | tmp.id;
+		// sout | task( dl ).id;
+	}
+	sout | nl;
+	for ( Lnth ) {										// remove nodes from readyList and safe to delete nodes
+		delete( &task( pop( mutexStack ) ) );
+	}
+}
Index: libcfa/src/bits/queue.hfa
===================================================================
--- libcfa/src/bits/queue.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/bits/queue.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -11,6 +11,6 @@
 	inline {
 		// wrappers to make Collection have T
-		T * head( Queue(T) & q ) with( q ) {
-			return (T *)head( (Collection &)q );
+		T & head( Queue(T) & q ) with( q ) {
+			return *(T *)head( (Collection &)q );
 		} // post: empty() & head() == 0 | !empty() & head() in *q
 
@@ -23,6 +23,6 @@
 		} // post: empty()
 
-		T * tail( Queue(T) & q ) with( q ) {
-			return last;
+		T & tail( Queue(T) & q ) with( q ) {
+			return *last;
 		}
 
@@ -34,58 +34,58 @@
 		} // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q
 
-		void addHead( Queue(T) & q, T * n ) with( q ) {
+		void addHead( Queue(T) & q, T & n ) with( q ) {
 #ifdef __CFA_DEBUG__
-			if ( listed( n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, n );
+			if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n );
 #endif // __CFA_DEBUG__
 			if ( last ) {
-				Next( n ) = head( q );
-				q.root = n;
+				Next( &n ) = &head( q );
+				q.root = &n;
 			} else {
-				root = last = n;
-				Next( n ) = n;							// last node points to itself
+				root = last = &n;
+				Next( &n ) = &n;							// last node points to itself
 			}
 		}
 
-		void addTail( Queue(T) & q, T * n ) with( q ) {
+		void addTail( Queue(T) & q, T & n ) with( q ) {
 #ifdef __CFA_DEBUG__
-			if ( listed( n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, n );
+			if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n );
 #endif // __CFA_DEBUG__
-			if ( last ) Next( last ) = n;
-			else root = n;
-			last = n;
-			Next( n ) = n;								// last node points to itself
+			if ( last ) Next( last ) = &n;
+			else root = &n;
+			last = &n;
+			Next( &n ) = &n;								// last node points to itself
 		}
 
-		void add( Queue(T) & q, T * n ) with( q ) {
+		void add( Queue(T) & q, T & n ) with( q ) {
 			addTail( q, n );
 		}
 
-		T * dropHead( Queue(T) & q ) with( q ) {
-			T * t = head( q );
+		T & dropHead( Queue(T) & q ) with( q ) {
+			T & t = head( q );
 			if ( root ) {
 				root = Next( root );
-				if ( head( q ) == t ) {
+				if ( &head( q ) == &t ) {
 					root = last = 0p;					// only one element
 				}
-				Next( t ) = 0p;
+				Next( &t ) = 0p;
 			}
 			return t;
 		}
 
-		T * drop( Queue(T) & q ) with( q ) {
+		T & drop( Queue(T) & q ) with( q ) {
 			return dropHead( q );
 		}
 
-		void remove( Queue(T) & q, T * n ) with( q ) {	// O(n)
+		void remove( Queue(T) & q, T & n ) with( q ) {	// O(n)
 #ifdef __CFA_DEBUG__
-			if ( ! listed( (Colable &)(*n) ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, n );
+			if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n );
 #endif // __CFA_DEBUG__
-			T * prev = 0;
+			T * prev = 0p;
 			T * curr = (T *)root;
 			for ( ;; ) {
-				if (n == curr) {						// found => remove
-					if ((T *)root == n) {
+				if ( &n == curr ) {						// found => remove
+					if ( (T *)root == &n ) {
 						dropHead( q );
-					} else if (last == n) {
+					} else if ( last == &n ) {
 						last = prev;
 						Next( last ) = last;
@@ -93,10 +93,10 @@
 						Next( prev ) = Next( curr );
 					}
-					Next( n ) = 0p;
+					Next( &n ) = 0p;
 					break;
 				}
 #ifdef __CFA_DEBUG__
 				// not found => error
-				if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, n );
+				if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
 #endif // __CFA_DEBUG__
 				prev = curr;
@@ -105,7 +105,7 @@
 		} // post: ! listed( n )
 
-		T * dropTail( Queue(T) & q ) with( q ) { // O(n)
-			T * n = tail( q );
-			return n ? remove( q, n ), n : 0p;
+		T & dropTail( Queue(T) & q ) with( q ) { // O(n)
+			T & n = tail( q );
+			return &n ? remove( q, n ), n : *0p;
 		}
 
@@ -116,5 +116,5 @@
 				root = from.root;
 			} else {									// "to" list not empty
-				Next( last ) = head( from );
+				Next( last ) = &head( from );
 			}
 			last = from.last;
@@ -124,16 +124,16 @@
 		// Transfer the "from" list up to node "n" to the end of queue list; the "from" list becomes the list after node "n".
 		// Node "n" must be in the "from" list.
-		void split( Queue(T) & q, Queue(T) & from, T * n ) with( q ) {
+		void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) {
 #ifdef __CFA_DEBUG__
-			if ( ! listed( (Colable &)(*n) ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, n );
+			if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n );
 #endif // __CFA_DEBUG__
 			Queue(T) to;
 			to.root = from.root;						// start of "to" list
-			to.last = n;								// end of "to" list
-			from.root = Next( n );						// start of "from" list
-			if ( n == head( from ) ) {					// last node in list ?
+			to.last = &n;								// end of "to" list
+			from.root = Next( &n );						// start of "from" list
+			if ( &n == &head( from ) ) {				// last node in list ?
 				from.root = from.last = 0p;				// mark "from" list empty
 			} else {
-				Next( n ) = n;							// fix end of "to" list
+				Next( &n ) = &n;						// fix end of "to" list
 			}
 			transfer( q, to );
@@ -154,14 +154,14 @@
 		// create an iterator active in Queue q
 		void ?{}( QueueIter(T) & qi, Queue(T) & q ) with( qi ) {
-			curr = head( q );
+			curr = &head( q );
 		} // post: curr = {e in q}
 
-		void ?{}( QueueIter(T) & qi, T * start ) with( qi ) {
-			curr = start;
+		void ?{}( QueueIter(T) & qi, T & start ) with( qi ) {
+			curr = &start;
 		} // post: curr = {e in q}
 
 		// make existing iterator active in Queue q
 		void over( QueueIter(T) & qi, Queue(T) & q ) with( qi ) {
-			curr = head( q );
+			curr = &head( q );
 		} // post: curr = {e in q}
 
@@ -179,4 +179,4 @@
 
 // Local Variables: //
-// compile-command: "make install" //
+// compile-command: "cfa queue.cfa" //
 // End: //
Index: libcfa/src/bits/queue_example.cfa
===================================================================
--- libcfa/src/bits/queue_example.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/bits/queue_example.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -27,5 +27,5 @@
 	
 	for ( i; 10 ) {
-		add( fred, new( 2 * i ) );
+		add( fred, *new( 2 * i ) );
 	}
 
@@ -36,5 +36,5 @@
 
 	for ( i; 9 ) {
-		delete( drop( fred ) );
+		delete( &drop( fred ) );
 	}
 
@@ -45,5 +45,5 @@
 	
 	for ( i; 10 ) {
-		add( fred, new( 2 * i + 1 ) );
+		add( fred, *new( 2 * i + 1 ) );
 	}
 	for ( over( fredIter, fred ); fredIter >> f; ) {
@@ -78,5 +78,5 @@
 	
 	for ( i; 10 ) {
-		add( mary, new( 2 * i ) );
+		add( mary, *new( 2 * i ) );
 	}
 
@@ -87,5 +87,5 @@
 	
 	for ( i; 9 ) {
-		delete( drop( mary ) );
+		delete( &drop( mary ) );
 	}
 
@@ -96,5 +96,5 @@
 	
 	for ( i; 10 ) {
-		add( mary, new( 2 * i + 1 ) );
+		add( mary, *new( 2 * i + 1 ) );
 	}
 	for ( over( maryIter, mary ); maryIter >> m; ) {
Index: libcfa/src/bits/sequence.hfa
===================================================================
--- libcfa/src/bits/sequence.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/bits/sequence.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -14,6 +14,6 @@
 	} // post: ! listed()
 
-	Seqable * getBack( Seqable & sq ) with( sq ) {
-		return back;
+	Seqable & getBack( Seqable & sq ) with( sq ) {
+		return *back;
 	}
 
@@ -30,6 +30,6 @@
 	inline {
 		// wrappers to make Collection have T
-		T * head( Sequence(T) & s ) with( s ) {
-			return (T *)head( (Collection &)s );
+		T & head( Sequence(T) & s ) with( s ) {
+			return *(T *)head( (Collection &)s );
 		} // post: empty() & head() == 0 | !empty() & head() in *s
 
@@ -47,5 +47,5 @@
 		// Return a pointer to the last sequence element, without removing it.	
 		T & tail( Sequence(T) & s ) with( s ) {
-			return root ? (T &)Back( head( s ) ) : *0p;	// needs cast?
+			return root ? (T &)*Back( &head( s ) ) : *0p;
 		}	// post: empty() & tail() == 0 | !empty() & tail() in *s
 
@@ -55,6 +55,6 @@
 			if ( ! listed( n ) ) abort( "(Sequence &)%p.succ( %p ) : Node is not on a list.", &s, n );
 #endif // __CFA_DEBUG__
-			return Next( n ) == head( s ) ? 0p : Next( n );
-		}	// post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s
+			return Next( n ) == &head( s ) ? 0p : Next( n );
+		} // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s
 
 		// Return a pointer to the element before *n, or 0p if there isn't one.
@@ -63,5 +63,5 @@
 			if ( ! listed( n ) ) abort( "(Sequence &)%p.pred( %p ) : Node is not on a list.", &s, n );
 #endif // __CFA_DEBUG__
-			return n == head( s ) ? 0p : Back( n );
+			return n == &head( s ) ? 0p : Back( n );
 		}	// post: n == head() & head(n) == 0 | n != head() & *pred(n) in *s
 
@@ -72,11 +72,11 @@
 			if ( listed( &n ) ) abort( "(Sequence &)%p.insertBef( %p, %p ) : Node is already on another list.", &s, n, &bef );
 #endif // __CFA_DEBUG__
-			if ( &bef == head( s ) ) {					// must change root
+			if ( &bef == &head( s ) ) {					// must change root
 				if ( root ) {
-					Next( &n ) = head( s );
-					Back( &n ) = Back( head( s ) );
+					Next( &n ) = &head( s );
+					Back( &n ) = Back( &head( s ) );
 					// inserted node must be consistent before it is seen
 					asm( "" : : : "memory" );			// prevent code movement across barrier
-					Back( head( s ) ) = &n;
+					Back( &head( s ) ) = &n;
 					Next( Back( &n ) ) = &n;
 				} else {
@@ -88,5 +88,5 @@
 				root = &n;
 			} else {
-				if ( ! &bef ) &bef = head( s );
+				if ( ! &bef ) &bef = &head( s );
 				Next( &n ) = &bef;
 				Back( &n ) = Back( &bef );
@@ -106,9 +106,9 @@
 			if ( ! &aft ) {								// must change root
 				if ( root ) {
-					Next( &n ) = head( s );
-					Back( &n ) = Back( head( s ) );
+					Next( &n ) = &head( s );
+					Back( &n ) = Back( &head( s ) );
 					// inserted node must be consistent before it is seen
 					asm( "" : : : "memory" );			// prevent code movement across barrier
-					Back( head( s ) ) = &n;
+					Back( &head( s ) ) = &n;
 					Next( Back( &n ) ) = &n;
 				} else {
@@ -133,7 +133,7 @@
 			if ( ! listed( &n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, &n );
 #endif // __CFA_DEBUG__
-			if ( &n == head( s ) ) {
-				if ( Next( head( s ) ) == head( s ) ) root = 0p;
-				else root = Next( head(s ) );
+			if ( &n == &head( s ) ) {
+				if ( Next( &head( s ) ) == &head( s ) ) root = 0p;
+				else root = Next( &head( s ) );
 			} // if
 			Back( Next( &n ) ) = Back( &n );
@@ -156,6 +156,6 @@
 		// Remove and return the head element in the sequence.
 		T & dropHead( Sequence(T) & s ) {
-			T * n = head( s );
-			return n ? remove( s, *n ), *n : *0p;
+			T & n = head( s );
+			return &n ? remove( s, n ), n : *0p;
 		}
 		// Remove and return the head element in the sequence.
@@ -175,10 +175,10 @@
 				root = from.root;
 			} else {									// "to" list not empty
-				T * toEnd = Back( head( s ) );
-				T * fromEnd = Back( head( from ) );
+				T * toEnd = Back( &head( s ) );
+				T * fromEnd = Back( &head( from ) );
 				Back( root ) = fromEnd;
-				Next( fromEnd ) = head( s );
+				Next( fromEnd ) = &head( s );
 				Back( from.root ) = toEnd;
-				Next( toEnd ) = head( from );
+				Next( toEnd ) = &head( from );
 			} // if
 			from.root = 0p;								// mark "from" list empty
@@ -187,18 +187,18 @@
 		// Transfer the "from" list up to node "n" to the end of s list; the "from" list becomes the sequence after node "n".
 		// Node "n" must be in the "from" list.
-		void split( Sequence(T) & s, Sequence(T) & from, T * n ) with( s ) {
-#ifdef __CFA_DEBUG__
-			if ( ! listed( n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, n );
+		void split( Sequence(T) & s, Sequence(T) & from, T & n ) with( s ) {
+#ifdef __CFA_DEBUG__
+			if ( ! listed( &n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, &n );
 #endif // __CFA_DEBUG__
 			Sequence(T) to;
 			to.root = from.root;						// start of "to" list
-			from.root = Next( n );						// start of "from" list
+			from.root = Next( &n );						// start of "from" list
 			if ( to.root == from.root ) {				// last node in list ?
 				from.root = 0p;							// mark "from" list empty
 			} else {
-				Back( head( from ) ) = Back( head( to ) ); // fix "from" list
-		 		Next( Back( head( to ) ) ) = head( from );
-				Next( n ) = head( to );					// fix "to" list
-				Back( head( to ) ) = n;
+				Back( &head( from ) ) = Back( &head( to ) ); // fix "from" list
+		 		Next( Back( &head( to ) ) ) = &head( from );
+				Next( &n ) = &head( to );					// fix "to" list
+				Back( &head( to ) ) = &n;
 			} // if
 			transfer( s, to );
@@ -211,4 +211,7 @@
 	struct SeqIter {
 		inline ColIter;
+		// The Sequence must be passed to pred and succ to check for the end of the Sequence and return 0p. Without
+		// passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence
+		// to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular.
 		Sequence(T) * seq;
 	};
@@ -223,10 +226,16 @@
 			((ColIter &) si){};
 			seq = &s;
-			curr = head( s );
-		} // post: elts = null.
-		
+			curr = &head( s );
+		} // post: elts = null.
+
+		void ?{}( SeqIter(T) & si, Sequence(T) & s, T & start ) with( si ) {
+			((ColIter &) si){};
+			seq = &s;
+			curr = &start;
+		} // post: elts = null.
+
 		void over( SeqIter(T) & si, Sequence(T) & s ) with( si ) {
 			seq = &s;
-			curr = head( s );
+			curr = &head( s );
 		} // post: elts = {e in s}.
 
@@ -235,5 +244,5 @@
 				&tp = Curr( si );
 				T * n = succ( *seq, Curr( si ) );
-				curr = n == head( *seq ) ? 0p : n;
+				curr = n == &head( *seq ) ? 0p : n;
 			} else &tp = 0p;
 			return &tp != 0p;
@@ -245,4 +254,5 @@
 	struct SeqIterRev {
 		inline ColIter;
+		// See above for explanation.
 		Sequence(T) * seq;
 	};
@@ -259,5 +269,11 @@
 			curr = &tail( s );
 		} // post: elts = null.
-		
+
+		void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) {	
+			((ColIter &) si){};
+			seq = &s;
+			curr = &start;
+		} // post: elts = null.
+
 		void over( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) {
 			seq = &s;
@@ -277,4 +293,4 @@
 
 // Local Variables: //
-// compile-command: "make install" //
+// compile-command: "cfa sequence.hfa" //
 // End: //
Index: libcfa/src/bits/stack.hfa
===================================================================
--- libcfa/src/bits/stack.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/bits/stack.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -10,6 +10,6 @@
 	inline {
 		// wrappers to make Collection have T
-		T * head( Stack(T) & s ) with( s ) {
-			return (T *)head( (Collection &)s );
+		T & head( Stack(T) & s ) with( s ) {
+			return *(T *)head( (Collection &)s );
 		} // post: empty() & head() == 0 | !empty() & head() in *this
 
@@ -22,5 +22,5 @@
 
 		T & top( Stack(T) & s ) with( s ) {
-			return *head( s );
+			return head( s );
 		}
 
@@ -29,5 +29,5 @@
 			if ( listed( (Colable &)(n) ) ) abort( "(Stack &)%p.addHead( %p ) : Node is already on another list.", &s, n );
 #endif // __CFA_DEBUG__
-			Next( &n ) = head( s ) ? head( s ) : &n;
+			Next( &n ) = &head( s ) ? &head( s ) : &n;
 			root = &n;
 		}
@@ -42,8 +42,8 @@
 
 		T & drop( Stack(T) & s ) with( s ) {
-			T & t = *head( s );
+			T & t = head( s );
 			if ( root ) {
 				root = ( T *)Next(root);
-				if ( head( s ) == &t ) root = 0p;		// only one element ?
+				if ( &head( s ) == &t ) root = 0p;		// only one element ?
 				Next( &t ) = 0p;
 			} // if
@@ -70,5 +70,5 @@
 		// create an iterator active in Stack s
 		void ?{}( StackIter(T) & si, Stack(T) & s ) with( si ) {
-			curr = head( s );
+			curr = &head( s );
 		} // post: curr = {e in s}
 
@@ -79,5 +79,5 @@
 		// make existing iterator active in Stack q
 		void over( StackIter(T) & si, Stack(T) & s ) with( si ) {
-			curr = head( s );
+			curr = &head( s );
 		} // post: curr = {e in s}
 
Index: libcfa/src/concurrency/alarm.cfa
===================================================================
--- libcfa/src/concurrency/alarm.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/alarm.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -60,6 +60,5 @@
 	type = Kernel;
 }
-void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ) with( this ) {
-	this.thrd = thrd;
+void ?{}( alarm_node_t & this, Alarm_Callback callback, Time alarm, Duration period ) with( this ) {
 	this.alarm = alarm;
 	this.period = period;
Index: libcfa/src/concurrency/alarm.hfa
===================================================================
--- libcfa/src/concurrency/alarm.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/alarm.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -52,9 +52,8 @@
 
 	union {
-		$thread * thrd;	// thrd who created event
-		processor * proc;		// proc who created event
+		$thread * thrd;					// thrd who created event
+		processor * proc;				// proc who created event
+		Alarm_Callback callback;		// callback to handle event
 	};
-
-	Alarm_Callback callback;
 
 	bool set		:1;		// whether or not the alarm has be registered
@@ -65,5 +64,5 @@
 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period );
 void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period );
-void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback );
+void ?{}( alarm_node_t & this, Alarm_Callback callback, Time alarm, Duration period );
 void ^?{}( alarm_node_t & this );
 
Index: libcfa/src/concurrency/io.cfa
===================================================================
--- libcfa/src/concurrency/io.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/io.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -160,5 +160,5 @@
 	static inline void process(struct io_uring_cqe & cqe ) {
 		struct io_future_t * future = (struct io_future_t *)(uintptr_t)cqe.user_data;
-		__cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", future, cqe.res, data->thrd );
+		__cfadbg_print_safe( io, "Kernel I/O : Syscall completed : cqe %p, result %d for %p\n", &cqe, cqe.res, future );
 
 		fulfil( *future, cqe.res );
@@ -298,7 +298,5 @@
 		__u32 mask = *ring.submit_q.mask;
 
-		disable_interrupts();
-			__u32 off = __tls_rand();
-		enable_interrupts( __cfaabi_dbg_ctx );
+		__u32 off = thread_rand();
 
 		// Loop around looking for an available spot
@@ -344,7 +342,5 @@
 		__u32 ready_mask = ring.submit_q.ready_cnt - 1;
 
-		disable_interrupts();
-			__u32 off = __tls_rand();
-		enable_interrupts( __cfaabi_dbg_ctx );
+		__u32 off = thread_rand();
 
 		__u32 picked;
Index: libcfa/src/concurrency/io/call.cfa.in
===================================================================
--- libcfa/src/concurrency/io/call.cfa.in	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/io/call.cfa.in	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -84,5 +84,5 @@
 
 		/* paranoid */ verifyf( cltr->io.ctxs, "default io contexts for cluster %p are missing\\n", cltr);
-		return &cltr->io.ctxs[ __tls_rand() % cltr->io.cnt ];
+		return &cltr->io.ctxs[ thread_rand() % cltr->io.cnt ];
 	}
 #endif
Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/kernel.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -619,4 +619,7 @@
 	lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
 
+	// disable interrupts, it no longer makes sense to try to interrupt this processor
+	disable_interrupts();
+
 	// first task to abort ?
 	if ( kernel_abort_called ) {			// not first task to abort ?
Index: libcfa/src/concurrency/kernel/fwd.hfa
===================================================================
--- libcfa/src/concurrency/kernel/fwd.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/kernel/fwd.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -132,4 +132,6 @@
 		}
 
+		extern uint64_t thread_rand();
+
 		//-----------------------------------------------------------------------
 		// Statics call at the end of each thread to register statistics
Index: libcfa/src/concurrency/locks.cfa
===================================================================
--- libcfa/src/concurrency/locks.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/locks.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -11,6 +11,8 @@
 //// info_thread
 ///////////////////////////////////////////////////////////////////
+
 forall(dtype L | is_blocking_lock(L)) {
 	void ?{}( info_thread(L) & this, $thread * t ) {
+		((Seqable &) this){};
 		this.t = t;
 		this.lock = 0p;
@@ -19,4 +21,5 @@
 
 	void ?{}( info_thread(L) & this, $thread * t, uintptr_t info ) {
+		((Seqable &) this){};
 		this.t = t;
 		this.info = info;
@@ -25,12 +28,7 @@
 	}
 
-	void ^?{}( info_thread(L) & this ){
-		// default
-	}
-
-	info_thread(L) *& get_next( info_thread(L) & this ) {
-		return this.next;
-	}
-}
+	void ^?{}( info_thread(L) & this ){ }
+}
+
 ///////////////////////////////////////////////////////////////////
 //// Blocking Locks
@@ -47,37 +45,16 @@
 }
 
-void ^?{}( blocking_lock & this ) {
-	// default
-}
-
-void ?{}( single_acquisition_lock & this ) {
-	((blocking_lock &)this){ false, false };
-}
-
-void ^?{}( single_acquisition_lock & this ) {
-	// default
-}
-
-void ?{}( owner_lock & this ) {
-	((blocking_lock &)this){ true, true };
-}
-
-void ^?{}( owner_lock & this ) {
-	// default
-}
-
-void ?{}( multiple_acquisition_lock & this ) {
-	((blocking_lock &)this){ true, false };
-}
-
-void ^?{}( multiple_acquisition_lock & this ) {
-	// default
-}
+void ^?{}( blocking_lock & this ) {}
+void ?{}( single_acquisition_lock & this ) {((blocking_lock &)this){ false, false };}
+void ^?{}( single_acquisition_lock & this ) {}
+void ?{}( owner_lock & this ) {((blocking_lock &)this){ true, true };}
+void ^?{}( owner_lock & this ) {}
+void ?{}( multiple_acquisition_lock & this ) {((blocking_lock &)this){ true, false };}
+void ^?{}( multiple_acquisition_lock & this ) {}
 
 void lock( blocking_lock & this ) with( this ) {
 	lock( lock __cfaabi_dbg_ctx2 );
 	if ( owner == active_thread() && !multi_acquisition) {
-		fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead
-    	exit(EXIT_FAILURE);
+		abort("A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock.");
 	} else if ( owner != 0p && owner != active_thread() ) {
 		append( blocked_threads, active_thread() );
@@ -110,20 +87,26 @@
 }
 
+void unlock_error_check( blocking_lock & this ) with( this ) {
+	if ( owner == 0p ){ // no owner implies lock isn't held
+		abort( "There was an attempt to release a lock that isn't held" ); 
+	} else if ( strict_owner && owner != active_thread() ) {
+		abort( "A thread other than the owner attempted to release an owner lock" ); 
+	}
+}
+
+void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
+	$thread * t = pop_head( blocked_threads );
+	owner = t;
+	recursion_count = ( t ? 1 : 0 );
+	wait_count--;
+	unpark( t );
+}
+
 void unlock( blocking_lock & this ) with( this ) {
 	lock( lock __cfaabi_dbg_ctx2 );
-	if ( owner == 0p ){ // no owner implies lock isn't held
-		fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 
-		return;
-	} else if ( strict_owner && owner != active_thread() ) {
-		fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 
-		return;
-	}
+	unlock_error_check( this );
 	recursion_count--;
 	if ( recursion_count == 0 ) {
-		$thread * thrd = pop_head( blocked_threads );
-		owner = thrd;
-		recursion_count = ( thrd ? 1 : 0 );
-		wait_count--;
-		unpark( thrd );
+		pop_and_set_new_owner( this );
 	}
 	unlock( lock );
@@ -133,5 +116,4 @@
 	return wait_count;
 }
-
 
 void set_recursion_count( blocking_lock & this, size_t recursion ) with( this ) {
@@ -152,7 +134,4 @@
 		owner = t;
 		recursion_count = 1;
-		#if !defined( __CFA_NO_STATISTICS__ )
-			//kernelTLS.this_stats = t->curr_cluster->stats;
-		#endif
 		unpark( t );
 		unlock( lock );
@@ -162,15 +141,6 @@
 void remove_( blocking_lock & this ) with( this ) {
     lock( lock __cfaabi_dbg_ctx2 );
-	if ( owner == 0p ){ // no owner implies lock isn't held
-		fprintf( stderr, "A lock that is not held was passed to a synchronization lock" ); 
-	} else if ( strict_owner && owner != active_thread() ) {
-		fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 
-	} else {
-		$thread * thrd = pop_head( blocked_threads );
-		owner = thrd;
-		recursion_count = ( thrd ? 1 : 0 );
-		wait_count--;
-		unpark( thrd );
-	}
+	unlock_error_check( this );
+	pop_and_set_new_owner( this );
 	unlock( lock );
 }
@@ -182,75 +152,24 @@
 // This is temporary until an inheritance bug is fixed
 
-void lock( single_acquisition_lock & this ){
-	lock( (blocking_lock &)this );
-}
-
-void unlock( single_acquisition_lock & this ){
-	unlock( (blocking_lock &)this );
-}
-
-void add_( single_acquisition_lock & this, struct $thread * t ){
-	add_( (blocking_lock &)this, t );
-}
-
-void remove_( single_acquisition_lock & this ){
-	remove_( (blocking_lock &)this );
-}
-
-void set_recursion_count( single_acquisition_lock & this, size_t recursion ){
-	set_recursion_count( (blocking_lock &)this, recursion );
-}
-
-size_t get_recursion_count( single_acquisition_lock & this ){
-	return get_recursion_count( (blocking_lock &)this );
-}
-
-void lock( owner_lock & this ){
-	lock( (blocking_lock &)this );
-}
-
-void unlock( owner_lock & this ){
-	unlock( (blocking_lock &)this );
-}
-
-void add_( owner_lock & this, struct $thread * t ){
-	add_( (blocking_lock &)this, t );
-}
-
-void remove_( owner_lock & this ){
-	remove_( (blocking_lock &)this );
-}
-
-void set_recursion_count( owner_lock & this, size_t recursion ){
-	set_recursion_count( (blocking_lock &)this, recursion );
-}
-
-size_t get_recursion_count( owner_lock & this ){
-	return get_recursion_count( (blocking_lock &)this );
-}
-
-void lock( multiple_acquisition_lock & this ){
-	lock( (blocking_lock &)this );
-}
-
-void unlock( multiple_acquisition_lock & this ){
-	unlock( (blocking_lock &)this );
-}
-
-void add_( multiple_acquisition_lock & this, struct $thread * t ){
-	add_( (blocking_lock &)this, t );
-}
-
-void remove_( multiple_acquisition_lock & this ){
-	remove_( (blocking_lock &)this );
-}
-
-void set_recursion_count( multiple_acquisition_lock & this, size_t recursion ){
-	set_recursion_count( (blocking_lock &)this, recursion );
-}
-
-size_t get_recursion_count( multiple_acquisition_lock & this ){
-	return get_recursion_count( (blocking_lock &)this );
-}
+void lock( single_acquisition_lock & this ){ lock( (blocking_lock &)this ); }
+void unlock( single_acquisition_lock & this ){ unlock( (blocking_lock &)this ); }
+void add_( single_acquisition_lock & this, struct $thread * t ){ add_( (blocking_lock &)this, t ); }
+void remove_( single_acquisition_lock & this ){ remove_( (blocking_lock &)this ); }
+void set_recursion_count( single_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
+size_t get_recursion_count( single_acquisition_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
+
+void lock( owner_lock & this ){ lock( (blocking_lock &)this ); }
+void unlock( owner_lock & this ){ unlock( (blocking_lock &)this ); }
+void add_( owner_lock & this, struct $thread * t ){ add_( (blocking_lock &)this, t ); }
+void remove_( owner_lock & this ){ remove_( (blocking_lock &)this ); }
+void set_recursion_count( owner_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
+size_t get_recursion_count( owner_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
+
+void lock( multiple_acquisition_lock & this ){ lock( (blocking_lock &)this ); }
+void unlock( multiple_acquisition_lock & this ){ unlock( (blocking_lock &)this ); }
+void add_( multiple_acquisition_lock & this, struct $thread * t ){ add_( (blocking_lock &)this, t ); }
+void remove_( multiple_acquisition_lock & this ){ remove_( (blocking_lock &)this ); }
+void set_recursion_count( multiple_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
+size_t get_recursion_count( multiple_acquisition_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
 
 ///////////////////////////////////////////////////////////////////
@@ -263,15 +182,13 @@
     	// This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
 	    lock( cond->lock __cfaabi_dbg_ctx2 );
-	    if ( (*i)->listed ) {			// is thread on queue
-	    	info_thread(L) * copy = *i;
-			remove( cond->blocked_threads, i );		 //remove this thread O(1)
+	    
+	    if ( i->listed ) {			// is thread on queue
+	    	cond->last_thread = i;		// REMOVE THIS AFTER DEBUG
+			remove( cond->blocked_threads, *i );		 //remove this thread O(1)
 			cond->count--;
-			if( !copy->lock ) {
-				#if !defined( __CFA_NO_STATISTICS__ )
-					//kernelTLS.this_stats = copy->t->curr_cluster->stats;
-				#endif
-				unpark( copy->t );
+			if( !i->lock ) {
+				unpark( i->t );
 	    	} else {
-	    		add_(*copy->lock, copy->t);			// call lock's add_
+	    		add_(*i->lock, i->t);			// call lock's add_
 	    	}
 	    }
@@ -279,7 +196,5 @@
 	}
 
-	void alarm_node_wrap_cast( alarm_node_t & a ) {
-		timeout_handler( (alarm_node_wrap(L) &)a );
-	}
+	void alarm_node_wrap_cast( alarm_node_t & a ) { timeout_handler( (alarm_node_wrap(L) &)a ); }
 
 	void ?{}( condition_variable(L) & this ){
@@ -287,31 +202,31 @@
 		this.blocked_threads{};
 		this.count = 0;
-	}
-
-	void ^?{}( condition_variable(L) & this ){
-		// default
-	}
-
-	void ?{}( alarm_node_wrap(L) & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ) {
-		this.alarm_node{ thrd, alarm, period, callback };
-	}
-
-	void ^?{}( alarm_node_wrap(L) & this ) {
-		// default
+		this.last_thread = 0p; // REMOVE AFTER DEBUG
+	}
+
+	void ^?{}( condition_variable(L) & this ){ }
+
+	void ?{}( alarm_node_wrap(L) & this, Time alarm, Duration period, Alarm_Callback callback ) {
+		this.alarm_node{ callback, alarm, period };
+	}
+
+	void ^?{}( alarm_node_wrap(L) & this ) { }
+
+	void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
+		if(&popped != 0p) {
+			popped.listed = false;
+			count--;
+			if (popped.lock) {
+				add_(*popped.lock, popped.t);
+			} else {
+				unpark(popped.t);
+			}
+		}
 	}
 
 	bool notify_one( condition_variable(L) & this ) with( this ) {
 		lock( lock __cfaabi_dbg_ctx2 );
-		bool ret = !!blocked_threads;
-		info_thread(L) * popped = pop_head( blocked_threads );
-		if(popped != 0p) {
-			popped->listed = false;
-			count--;
-			if (popped->lock) {
-				add_(*popped->lock, popped->t);
-			} else {
-				unpark(popped->t);
-			}
-		}
+		bool ret = !empty(blocked_threads);
+		process_popped(this, dropHead( blocked_threads ));
 		unlock( lock );
 		return ret;
@@ -320,16 +235,7 @@
 	bool notify_all( condition_variable(L) & this ) with(this) {
 		lock( lock __cfaabi_dbg_ctx2 );
-		bool ret = blocked_threads ? true : false;
-		while( blocked_threads ) {
-			info_thread(L) * popped = pop_head( blocked_threads );
-			if(popped != 0p){
-				popped->listed = false;
-				count--;
-				if (popped->lock) {
-					add_(*popped->lock, popped->t);
-				} else {
-					unpark(popped->t);
-				}
-			}
+		bool ret = !empty(blocked_threads);
+		while( !empty(blocked_threads) ) {
+			process_popped(this, dropHead( blocked_threads ));
 		}
 		unlock( lock );
@@ -338,31 +244,30 @@
 
 	uintptr_t front( condition_variable(L) & this ) with(this) {
-		if(!blocked_threads) return NULL;
-		return peek(blocked_threads)->info;
-	}
-
-	bool empty( condition_variable(L) & this ) with(this) {
-		return blocked_threads ? false : true;
-	}
-
-	int counter( condition_variable(L) & this ) with(this) {
-		return count;
-	}
-
-	// helper for wait()'s' without a timeout
+		return empty(blocked_threads) ? NULL : head(blocked_threads).info;
+	}
+
+	bool empty( condition_variable(L) & this ) with(this) { return empty(blocked_threads); }
+
+	int counter( condition_variable(L) & this ) with(this) { return count; }
+
+	size_t queue_and_get_recursion( condition_variable(L) & this, info_thread(L) * i ) with(this) {
+		addTail( blocked_threads, *i );
+		count++;
+		i->listed = true;
+		size_t recursion_count = 0;
+		if (i->lock) {
+			i->t->link.next = 1p;
+			recursion_count = get_recursion_count(*i->lock);
+			remove_( *i->lock );
+		}
+		return recursion_count;
+	}
+
+	// helper for wait()'s' with no timeout
 	void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) {
 		lock( lock __cfaabi_dbg_ctx2 );
-		append( this.blocked_threads, &i );
-		count++;
-		i.listed = true;
-		size_t recursion_count;
-		if (i.lock) {
-			recursion_count = get_recursion_count(*i.lock);
-			remove_( *i.lock );
-		}
-		
+		size_t recursion_count = queue_and_get_recursion(this, &i);
 		unlock( lock );
 		park( ); // blocks here
-
 		if (i.lock) set_recursion_count(*i.lock, recursion_count); // resets recursion count here after waking
 	}
@@ -371,26 +276,12 @@
 	void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Time t ) with(this) {
 		lock( lock __cfaabi_dbg_ctx2 );
-
-		info_thread(L) * queue_ptr = &info;
-
-		alarm_node_wrap(L) node_wrap = { info.t, t, 0`s, alarm_node_wrap_cast };
+		size_t recursion_count = queue_and_get_recursion(this, &info);
+		alarm_node_wrap(L) node_wrap = { t, 0`s, alarm_node_wrap_cast };
 		node_wrap.cond = &this;
-		node_wrap.i = &queue_ptr;
-
+		node_wrap.i = &info;
 		register_self( &node_wrap.alarm_node );
-
-		append( blocked_threads, queue_ptr );
-		info.listed = true;
-		count++;
-
-		size_t recursion_count;
-		if (info.lock) {
-			recursion_count = get_recursion_count(*info.lock);
-			remove_( *info.lock );
-		}
-
 		unlock( lock );
 		park();
-
+		unregister_self( &node_wrap.alarm_node );
 		if (info.lock) set_recursion_count(*info.lock, recursion_count);
 	}
@@ -462,54 +353,2 @@
 	}
 }
-
-// thread T1 {};
-// thread T2 {};
-
-// multiple_acquisition_lock m;
-// condition_variable( multiple_acquisition_lock ) c;
-
-// void main( T1 & this ) {
-// 	printf("T1 start\n");
-// 	lock(m);
-// 	printf("%d\n", counter(c));
-// 	if(empty(c)) {
-// 		printf("T1 wait\n");
-// 		wait(c,m,12);
-// 	}else{
-// 		printf("%d\n", front(c));
-// 		notify_one(c);
-// 	}
-// 	unlock(m);
-// 	printf("curr thd in main %p \n", active_thread());
-// 	printf("T1 waits for 2s\n");
-// 	lock(m);
-// 	wait( c, m, 2`s );
-// 	unlock(m);
-// 	printf("T1 wakes\n");
-// 	printf("T1 done\n");
-// }
-
-// void main( T2 & this ) {
-// 	printf("T2 start\n");
-// 	lock(m);
-// 	printf("%d\n", counter(c));
-// 	if(empty(c)) {
-// 		printf("T2 wait\n");
-// 		wait(c,m,12);
-// 	}else{
-// 		printf("%d\n", front(c));
-// 		notify_one(c);
-// 	}
-// 	unlock(m);
-// 	printf("T2 done\n");
-// }
-
-// int main() {
-// 	printf("start\n");
-// 	processor p[2];
-// 	{
-// 		T1 t1;
-// 		T2 t2;
-// 	}
-// 	printf("done\n");
-// }
Index: libcfa/src/concurrency/locks.hfa
===================================================================
--- libcfa/src/concurrency/locks.hfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/locks.hfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -5,4 +5,5 @@
 #include "bits/algorithm.hfa"
 #include "bits/locks.hfa"
+#include "bits/sequence.hfa"
 #include "bits/containers.hfa"
 
@@ -31,7 +32,7 @@
 forall(dtype L | is_blocking_lock(L)) {
 	struct info_thread {
+		inline Seqable;
 		struct $thread * t;
 		uintptr_t info;
-		info_thread(L) * next;
 		L * lock;
 		bool listed;					// true if info_thread is on queue, false otherwise;
@@ -42,6 +43,4 @@
 	void ?{}( info_thread(L) & this, $thread * t, uintptr_t info );
 	void ^?{}( info_thread(L) & this );
-
-	info_thread(L) *& get_next( info_thread(L) & this );
 }
 
@@ -50,4 +49,14 @@
 ///////////////////////////////////////////////////////////////////
 
+// struct lock_thread {
+// 	struct $thread * t;
+// 	lock_thread * next;
+// };
+
+// void ?{}( lock_thread & this, struct $thread * thd );
+// void ^?{}( lock_thread & this );
+
+// lock_thread *& get_next( lock_thread & );
+
 struct blocking_lock {
 	// Spin lock used for mutual exclusion
@@ -55,5 +64,5 @@
 
 	// List of blocked threads
-	__queue_t( struct $thread ) blocked_threads;
+	__queue_t( $thread ) blocked_threads;
 
 	// Count of current blocked threads
@@ -135,6 +144,8 @@
 		__spinlock_t lock;
 
+		info_thread(L) * last_thread;
+
 		// List of blocked threads
-		__queue_t( info_thread(L) ) blocked_threads;
+		Sequence( info_thread(L) ) blocked_threads;
 
 		// Count of current blocked threads
@@ -150,8 +161,8 @@
 		condition_variable(L) * cond;
 
-		info_thread(L) ** i;
+		info_thread(L) * i;
 	};
 
-	void ?{}( alarm_node_wrap(L) & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback );
+	void ?{}( alarm_node_wrap(L) & this, Time alarm, Duration period, Alarm_Callback callback );
 	void ^?{}( alarm_node_wrap(L) & this );
 
Index: libcfa/src/concurrency/thread.cfa
===================================================================
--- libcfa/src/concurrency/thread.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/concurrency/thread.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -162,4 +162,11 @@
 }
 
+uint64_t thread_rand() {
+	disable_interrupts();
+	uint64_t ret = __tls_rand();
+	enable_interrupts( __cfaabi_dbg_ctx );
+	return ret;
+}
+
 // Local Variables: //
 // mode: c //
Index: libcfa/src/interpose.cfa
===================================================================
--- libcfa/src/interpose.cfa	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ libcfa/src/interpose.cfa	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -220,26 +220,50 @@
 }
 
+static volatile int __abort_stage = 0;
+
 // Cannot forward va_list.
 void __abort( bool signalAbort, const char fmt[], va_list args ) {
-	void * kernel_data = kernel_abort();				// must be done here to lock down kernel
-	int len;
-
-	signal( SIGABRT, SIG_DFL );							// prevent final "real" abort from recursing to handler
-
-	len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
-	__cfaabi_bits_write( STDERR_FILENO, abort_text, len );
-
-	assert( fmt );
-	len = vsnprintf( abort_text, abort_text_size, fmt, args );
-	__cfaabi_bits_write( STDERR_FILENO, abort_text, len );
-
-	if ( fmt[strlen( fmt ) - 1] != '\n' ) {				// add optional newline if missing at the end of the format text
-		__cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
-	} // if
-	kernel_abort_msg( kernel_data, abort_text, abort_text_size );
-
-	__cfaabi_backtrace( signalAbort ? 4 : 2 );
-
-	__cabi_libc.abort();								// print stack trace in handler
+	int stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
+
+	// First stage: stop the cforall kernel and print
+	if(stage == 1) {
+		// increment stage
+		stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
+
+		// must be done here to lock down kernel
+		void * kernel_data = kernel_abort();
+		int len;
+
+		signal( SIGABRT, SIG_DFL );							// prevent final "real" abort from recursing to handler
+
+		len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
+		__cfaabi_bits_write( STDERR_FILENO, abort_text, len );
+
+		assert( fmt );
+		len = vsnprintf( abort_text, abort_text_size, fmt, args );
+		__cfaabi_bits_write( STDERR_FILENO, abort_text, len );
+
+		// add optional newline if missing at the end of the format text
+		if ( fmt[strlen( fmt ) - 1] != '\n' ) {
+			__cfaabi_bits_write( STDERR_FILENO, "\n", 1 );
+		} // if
+		kernel_abort_msg( kernel_data, abort_text, abort_text_size );
+	}
+
+	// Second stage: print the backtrace
+	if(stage == 2) {
+		// increment stage
+		stage = __atomic_add_fetch( &__abort_stage, 1, __ATOMIC_SEQ_CST );
+
+		// print stack trace in handler
+		__cfaabi_backtrace( signalAbort ? 4 : 2 );
+	}
+
+	do {
+		// Finally call abort
+		__cabi_libc.abort();
+
+		// Loop so that we never return
+	} while(true);
 }
 
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -131,31 +131,16 @@
 
 	void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt ) {
-		Indenter indent = { indentAmt };
-
-		std::vector<int> idx;
-		idx.reserve(list.size());
-		for(int i = 0; i < list.size(); i++) { idx.push_back(i); }
-
-		std::sort(idx.begin(), idx.end(), [&list](int lhs_idx, int rhs_idx) -> bool {
-			const auto & lhs = list.at(lhs_idx);
-			const auto & rhs = list.at(rhs_idx);
-			if(lhs.expr->location.startsBefore(rhs.expr->location)) return true;
-			if(rhs.expr->location.startsBefore(lhs.expr->location)) return false;
-
-			if(lhs.env.size() < rhs.env.size()) return true;
-			if(lhs.env.size() > rhs.env.size()) return false;
-
-			if(lhs.openVars.size() < rhs.openVars.size()) return true;
-			if(lhs.openVars.size() > rhs.openVars.size()) return false;
-
-			if(lhs.need.size() < rhs.need.size()) return true;
-			if(lhs.need.size() > rhs.need.size()) return false;
-
-			return false;
-		});
-
-		for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
-			i->print( os, indent );
-			os << std::endl;
+		std::vector<std::string> sorted;
+		sorted.reserve(list.size());
+		for(const auto & c : list) {
+			std::stringstream ss;
+			c.print( ss, indentAmt );
+			sorted.push_back(ss.str());
+		}
+
+		std::sort(sorted.begin(), sorted.end());
+
+		for ( const auto & s : sorted ) {
+			os << s << std::endl;
 		}
 	}
Index: src/ResolvExpr/Candidate.cpp
===================================================================
--- src/ResolvExpr/Candidate.cpp	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ src/ResolvExpr/Candidate.cpp	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -41,7 +41,16 @@
 
 void print( std::ostream & os, const CandidateList & cands, Indenter indent ) {
-	for ( const CandidateRef & cand : cands ) {
-		print( os, *cand, indent );
-		os << std::endl;
+	std::vector<std::string> sorted;
+	sorted.reserve(cands.size());
+	for(const auto & c : cands) {
+		std::stringstream ss;
+		print( ss, *c, indent );
+		sorted.push_back(ss.str());
+	}
+
+	std::sort(sorted.begin(), sorted.end());
+
+	for ( const auto & s : sorted ) {
+		os << s << std::endl;
 	}
 }
Index: tests/.expect/castError.nast.txt
===================================================================
--- tests/.expect/castError.nast.txt	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ tests/.expect/castError.nast.txt	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -7,7 +7,7 @@
   char Alternatives are:
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: f: signed int
+      Variable Expression: f: double
       ... with resolved type:
-        signed int
+        double
     ... to:
       char
@@ -39,7 +39,7 @@
 
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: f: double
+      Variable Expression: f: signed int
       ... with resolved type:
-        double
+        signed int
     ... to:
       char
Index: tests/.expect/castError.oast.txt
===================================================================
--- tests/.expect/castError.oast.txt	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ tests/.expect/castError.oast.txt	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -6,4 +6,17 @@
 with resolved type:
   char Alternatives are:
+Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
+      Variable Expression: f: double
+      with resolved type:
+        double
+    ... to:
+      char
+    with resolved type:
+      char
+  (types:
+    char
+  )
+  Environment:
+
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
       Variable Expression: f: function
@@ -16,17 +29,4 @@
         ... returning nothing
 
-    ... to:
-      char
-    with resolved type:
-      char
-  (types:
-    char
-  )
-  Environment:
-
-Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: f: double
-      with resolved type:
-        double
     ... to:
       char
@@ -67,9 +67,9 @@
         with resolved type:
           signed int
-        Variable Expression: v: unsigned char
+        Variable Expression: v: signed short int
         with resolved type:
-          unsigned char
+          signed short int
       with resolved type:
-        unsigned char
+        signed short int
     ... to: nothing
     with resolved type:
@@ -85,9 +85,9 @@
         with resolved type:
           signed int
-        Variable Expression: v: signed short int
+        Variable Expression: v: unsigned char
         with resolved type:
-          signed short int
+          unsigned char
       with resolved type:
-        signed short int
+        unsigned char
     ... to: nothing
     with resolved type:
Index: tests/errors/.expect/completeType.nast.x64.txt
===================================================================
--- tests/errors/.expect/completeType.nast.x64.txt	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ tests/errors/.expect/completeType.nast.x64.txt	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -9,4 +9,39 @@
 ... with resolved type:
   void Alternatives are:
+Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
+      Application of
+        Variable Expression: *?: forall
+          DT: data type
+          function
+        ... with parameters
+          pointer to instance of type DT (not function type)
+        ... returning
+          reference to instance of type DT (not function type)
+
+        ... with resolved type:
+          pointer to forall
+            [unbound]:data type
+            function
+          ... with parameters
+            pointer to instance of type [unbound] (not function type)
+          ... returning
+            reference to instance of type [unbound] (not function type)
+
+        ... to arguments
+        Variable Expression: x: pointer to instance of struct A without body
+        ... with resolved type:
+          pointer to instance of struct A without body
+
+      ... with resolved type:
+        reference to instance of struct A without body
+    ... to: nothing
+    ... with resolved type:
+      void
+  (types:
+    void
+  )
+  Environment:([unbound]) -> instance of struct A without body (no widening)
+
+
 Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
       Application of
@@ -42,39 +77,4 @@
   )
   Environment:([unbound]) -> instance of struct B with body (no widening)
-
-
-Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
-      Application of
-        Variable Expression: *?: forall
-          DT: data type
-          function
-        ... with parameters
-          pointer to instance of type DT (not function type)
-        ... returning
-          reference to instance of type DT (not function type)
-
-        ... with resolved type:
-          pointer to forall
-            [unbound]:data type
-            function
-          ... with parameters
-            pointer to instance of type [unbound] (not function type)
-          ... returning
-            reference to instance of type [unbound] (not function type)
-
-        ... to arguments
-        Variable Expression: x: pointer to instance of struct A without body
-        ... with resolved type:
-          pointer to instance of struct A without body
-
-      ... with resolved type:
-        reference to instance of struct A without body
-    ... to: nothing
-    ... with resolved type:
-      void
-  (types:
-    void
-  )
-  Environment:([unbound]) -> instance of struct A without body (no widening)
 
 
Index: tests/meta/.expect/archVast.nast.x64.txt
===================================================================
--- tests/meta/.expect/archVast.nast.x64.txt	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ tests/meta/.expect/archVast.nast.x64.txt	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -7,7 +7,7 @@
   char Alternatives are:
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: FX64: signed int
+      Variable Expression: FX64: double
       ... with resolved type:
-        signed int
+        double
     ... to:
       char
@@ -39,7 +39,7 @@
 
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: FX64: double
+      Variable Expression: FX64: signed int
       ... with resolved type:
-        double
+        signed int
     ... to:
       char
Index: tests/meta/.expect/archVast.oast.x64.txt
===================================================================
--- tests/meta/.expect/archVast.oast.x64.txt	(revision ab0257b9b49bb86a2eb216959cb6346d633a6414)
+++ tests/meta/.expect/archVast.oast.x64.txt	(revision 54f89d5cfc99d638a1cae2ddc034b8faff4e656c)
@@ -6,4 +6,17 @@
 with resolved type:
   char Alternatives are:
+Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
+      Variable Expression: FX64: double
+      with resolved type:
+        double
+    ... to:
+      char
+    with resolved type:
+      char
+  (types:
+    char
+  )
+  Environment:
+
 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
       Variable Expression: FX64: function
@@ -16,17 +29,4 @@
         ... returning nothing
 
-    ... to:
-      char
-    with resolved type:
-      char
-  (types:
-    char
-  )
-  Environment:
-
-Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
-      Variable Expression: FX64: double
-      with resolved type:
-        double
     ... to:
       char
