Index: tests/.expect/declarationSpecifier.x64.txt
===================================================================
--- tests/.expect/declarationSpecifier.x64.txt	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/.expect/declarationSpecifier.x64.txt	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -1132,5 +1132,5 @@
 char **_X13cfa_args_argvPPc_1;
 char **_X13cfa_args_envpPPc_1;
-signed int _X17cfa_main_returnedi_1 = ((signed int )0);
+__attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1;
 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
     __attribute__ ((unused)) signed int _X12_retval_maini_1;
@@ -1149,6 +1149,9 @@
     signed int _tmp_cp_ret6;
     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
-    {
-        ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
+        {
+            ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+        }
+
     }
 
Index: tests/.expect/declarationSpecifier.x86.txt
===================================================================
--- tests/.expect/declarationSpecifier.x86.txt	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/.expect/declarationSpecifier.x86.txt	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -1132,5 +1132,5 @@
 char **_X13cfa_args_argvPPc_1;
 char **_X13cfa_args_envpPPc_1;
-signed int _X17cfa_main_returnedi_1 = ((signed int )0);
+__attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1;
 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
     __attribute__ ((unused)) signed int _X12_retval_maini_1;
@@ -1149,6 +1149,9 @@
     signed int _tmp_cp_ret6;
     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
-    {
-        ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
+        {
+            ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+        }
+
     }
 
Index: tests/.expect/gccExtensions.x64.txt
===================================================================
--- tests/.expect/gccExtensions.x64.txt	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/.expect/gccExtensions.x64.txt	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -324,5 +324,5 @@
 char **_X13cfa_args_argvPPc_1;
 char **_X13cfa_args_envpPPc_1;
-signed int _X17cfa_main_returnedi_1 = ((signed int )0);
+__attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1;
 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
     __attribute__ ((unused)) signed int _X12_retval_maini_1;
@@ -341,6 +341,9 @@
     signed int _tmp_cp_ret6;
     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
-    {
-        ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
+        {
+            ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+        }
+
     }
 
Index: tests/.expect/gccExtensions.x86.txt
===================================================================
--- tests/.expect/gccExtensions.x86.txt	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/.expect/gccExtensions.x86.txt	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -302,5 +302,5 @@
 char **_X13cfa_args_argvPPc_1;
 char **_X13cfa_args_envpPPc_1;
-signed int _X17cfa_main_returnedi_1 = ((signed int )0);
+__attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1;
 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
     __attribute__ ((unused)) signed int _X12_retval_maini_1;
@@ -319,6 +319,9 @@
     signed int _tmp_cp_ret6;
     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
-    {
-        ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+    if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) {
+        {
+            ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
+        }
+
     }
 
Index: tests/concurrent/semaphore.cfa
===================================================================
--- tests/concurrent/semaphore.cfa	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/concurrent/semaphore.cfa	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -2,4 +2,5 @@
 #include <locks.hfa>
 #include <thread.hfa>
+#include <mutex_stmt.hfa>
 
 enum { num_blockers = 17, num_unblockers = 13 };
@@ -28,5 +29,5 @@
 		thrash();
 		P(ben);
-		if(((thread&)this).seqable.next != 0p) sout | acquire |"Link not invalidated";
+		if(((thread&)this).seqable.next != 0p) mutex(sout) sout | "Link not invalidated";
 		thrash();
 	}
Index: tests/concurrent/sleep.cfa
===================================================================
--- tests/concurrent/sleep.cfa	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/concurrent/sleep.cfa	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -1,4 +1,5 @@
 #include <fstream.hfa>
 #include <thread.hfa>
+#include <mutex_stmt.hfa>
 #include <time.hfa>
 
@@ -29,5 +30,5 @@
 
 int main() {
-	sout | acquire | "start";
+	mutex( sout ) sout | "start";
 	{
 		slow_sleeper slow;
@@ -36,5 +37,5 @@
 		yield();
 	}
-	sout | acquire | "done";
+	mutex( sout ) sout | "done";
 }
 
Index: tests/io/io-acquire.cfa
===================================================================
--- tests/io/io-acquire.cfa	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/io/io-acquire.cfa	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -10,10 +10,11 @@
 // Created On       : Mon Mar  1 18:40:09 2021
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Apr 27 11:49:34 2021
-// Update Count     : 18
+// Last Modified On : Wed Oct  6 18:04:58 2021
+// Update Count     : 72
 // 
 
 #include <fstream.hfa>
 #include <thread.hfa>
+#include <mutex_stmt.hfa>
 
 thread T {};
@@ -21,9 +22,8 @@
 	// output from parallel threads should not be scrambled
 
-	for ( 100 ) {										// local protection
-		sout | acquire | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
+	for ( 100 ) {										// expression protection
+		mutex(sout) sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
 	}
-	{													// global protection (RAII)
-		osacquire acq = { sout };
+	mutex( sout ) {										// statement protection
 		for ( 100 ) {
 			sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
@@ -31,9 +31,17 @@
 	}
 	{													// duplicate protection demonstrating recursive lock
-		osacquire acq = { sout };
-		for ( 100 ) {
-			osacquire acq = { sout };
-			sout | acquire | 1 | 2 | 3 | 4 | 5 | acquire | 6 | 7 | 8 | 9;
-			sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
+		ofstream & h1( ofstream & os ) {				// helper
+			mutex( os ) return os | 1 | 2 | 3 | 4;		// unnecessary mutex
+		}
+		ofstream & h2( ofstream & os ) {				// helper
+			mutex( os ) return os | 6 | 7 | 8 | 9;		// unnecessary mutex
+		}
+		mutex( sout ) {									// unnecessary mutex
+			for ( 100 ) {
+				mutex( sout ) {
+					sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
+					sout | h1 | 5 | h2;					// refactored code
+				}
+			}
 		}
 	}
@@ -42,9 +50,8 @@
 
 	int a, b, c, d, e, f, g, h, i;
-	for ( 100 ) {										// local protection
-		sin | acquire | a | b | c | d | e | f | g | h | i;
+	for ( 100 ) {										// expression protection
+		mutex(sin) sin | a | b | c | d | e | f | g | h | i;
 	}
-	{													// global protection (RAII)
-		isacquire acq = { sin };
+	mutex( sin ) {										// statement protection
 		for ( 100 ) {
 			sin  | a | b | c | d | e | f | g | h | i;
@@ -52,9 +59,17 @@
 	}
 	{													// duplicate protection demonstrating recursive lock
-		isacquire acq = { sin };
-		for ( 100 ) {
-			isacquire acq = { sin };
-			sin | acquire | a | b | c | d | e | acquire | f | g | h | i;
-			sin | a | b | c | d | e | f | g | h | i;
+		ifstream & h1( ifstream & is ) {				// helper
+			mutex( is ) return is | a | b | c | d;		// unnecessary mutex
+		}
+		ifstream & h2( ifstream & is ) {				// helper
+			mutex( is ) return is | f | g | h | i;		// unnecessary mutex
+		}
+		mutex( sin ) {									// unnecessary mutex
+			for ( 5 ) {
+				mutex( sin ) {
+					sin  | a | b | c | d | e | f | g | h | i;
+					sin  | h1 | e | h2;					// refactored code
+				}
+			}
 		}
 	}
Index: tests/linking/io-acquire.cfa
===================================================================
--- tests/linking/io-acquire.cfa	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/linking/io-acquire.cfa	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -17,12 +17,13 @@
 #include <fstream.hfa>
 #include <stdlib.hfa>
+#include <mutex_stmt.hfa>
 
 int main() {
 	int i;
 	if(threading_enabled()) {
-		stdout | acquire | "YES";
+		mutex( stdout ) stdout | "YES";
 		stdin | i;
 	} else {
-		stdout | acquire | "NO";
+		mutex( stdout ) stdout | "NO";
 		stdin | i;
 	}
Index: tests/pybin/test_run.py
===================================================================
--- tests/pybin/test_run.py	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/pybin/test_run.py	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -65,12 +65,12 @@
 	def toString( cls, retcode, duration ):
 		if settings.generating :
-			if   retcode == TestResult.SUCCESS: 	text = "Done   "
-			elif retcode == TestResult.TIMEOUT: 	text = "TIMEOUT"
-			else :						text = "ERROR code %d" % retcode
+			if   retcode == TestResult.SUCCESS: 	key = 'pass'; text = "Done   "
+			elif retcode == TestResult.TIMEOUT: 	key = 'time'; text = "TIMEOUT"
+			else :	key = 'fail';	text = "ERROR code %d" % retcode
 		else :
-			if   retcode == TestResult.SUCCESS: 	text = "PASSED "
-			elif retcode == TestResult.TIMEOUT: 	text = "TIMEOUT"
-			else :						text = "FAILED with code %d" % retcode
+			if   retcode == TestResult.SUCCESS: 	key = 'pass'; text = "PASSED "
+			elif retcode == TestResult.TIMEOUT: 	key = 'time'; text = "TIMEOUT"
+			else :	key = 'fail';	text = "FAILED with code %d" % retcode
 
 		text += "    C%s - R%s" % (fmtDur(duration[0]), fmtDur(duration[1]))
-		return text
+		return key, text
Index: tests/test.py
===================================================================
--- tests/test.py	(revision fefd77adcd0a40d9ea468278e2369a92cfd9e773)
+++ tests/test.py	(revision 7770cc8a0981a8a6485f2ec3ee49b6a51f60afde)
@@ -257,5 +257,5 @@
 
 		# update output based on current action
-		result_txt = TestResult.toString( retcode, duration )
+		result_key, result_txt = TestResult.toString( retcode, duration )
 
 		#print result with error if needed
@@ -265,7 +265,7 @@
 			text = text + '\n' + error
 
-		return retcode == TestResult.SUCCESS, text
+		return retcode == TestResult.SUCCESS, result_key, text
 	except KeyboardInterrupt:
-		return False, ""
+		return False, 'keybrd', ""
 	# except Exception as ex:
 	# 	print("Unexpected error in worker thread running {}: {}".format(t.target(), ex), file=sys.stderr)
@@ -283,4 +283,6 @@
 
 	failed = False
+	rescnts = {	'pass': 0, 'fail': 0, 'time': 0, 'keybrd': 0 }
+	other = 0
 
 	# for each test to run
@@ -294,5 +296,10 @@
 		)
 
-		for i, (succ, txt) in enumerate(timed(results, timeout = settings.timeout.total), 1) :
+		for i, (succ, code, txt) in enumerate(timed(results, timeout = settings.timeout.total), 1) :
+			if code in rescnts.keys():
+				rescnts[code] += 1
+			else:
+				other += 1
+
 			if not succ :
 				failed = True
@@ -319,4 +326,6 @@
 	# clean the workspace
 	make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
+
+	print("{} passes, {} failures, {} timeouts, {} cancelled, {} other".format(rescnts['pass'], rescnts['fail'], rescnts['time'], rescnts['keybrd'], other))
 
 	return failed
@@ -443,5 +452,4 @@
 			failed = run_tests(local_tests, options.jobs)
 			if failed:
-				result = 1
 				if not settings.continue_:
 					break
