diff --git a/test/haxe/src/Arguments.hx b/test/haxe/src/Arguments.hx
index ae23fa1..132f208 100644
--- a/test/haxe/src/Arguments.hx
+++ b/test/haxe/src/Arguments.hx
@@ -30,299 +30,299 @@
 
 
 enum ProtocolType {
-	binary;
-	json;
+    binary;
+    json;
 }
 
 enum EndpointTransport {
-	socket;
-	http;	
+    socket;
+    http;
 }
 
 enum ServerType {
-	simple;
-	/*
-	threadpool;	
-	threaded;
-	nonblocking;
-	*/
+    simple;
+    /*
+    threadpool;
+    threaded;
+    nonblocking;
+    */
 }
 
 
 class Arguments
 {
-	public var printHelpOnly(default,null) : Bool = false;
+    public var printHelpOnly(default,null) : Bool = false;
 
-	public var server(default,null) : Bool = false;
-	public var servertype(default,null) : ServerType = simple;
+    public var server(default,null) : Bool = false;
+    public var servertype(default,null) : ServerType = simple;
 
-	public var host(default,null) : String = "localhost";
-	public var port(default,null) : Int = 9090;
-	
-	public var protocol(default,null) : ProtocolType = binary;
-	public var transport(default,null) : EndpointTransport = socket;
-	public var framed(default,null) : Bool = false;
-	public var buffered(default,null) : Bool = false;
+    public var host(default,null) : String = "localhost";
+    public var port(default,null) : Int = 9090;
 
-	public var numIterations(default,null) : Int = 1;
-	public var numThreads(default,null) : Int = 1;
-	public var skipSpeedTest(default,null) : Bool = false;
-	
-	
-	public function new() {
-		#if sys
-		try {
-  			ParseArgs();
-		} catch (e : String) {
-			trace(GetHelp());
-			throw e;
-		}
-		#else
-		trace("WN: Platform does not support program arguments, using defaults.");
-		#end
-	}
-	
-	#if sys
-		
-	private static function GetHelp() : String {
-		var sProg = Path.withoutDirectory( Sys.executablePath());
-		return "\n"
-			+sProg+"  [client|server]  [options]\n"
-			+"\n"
-			+"Modus: Either client or server, the default is client.\n"
-			+"\n"
-			+"Common options:\n"
-			+"  -h [ --help ]               produce help message\n"
-			+"  --port arg (=9090)          Port number to listen / connect to\n"
-			/* not supported yet
-			+"  --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)\n"
+    public var protocol(default,null) : ProtocolType = binary;
+    public var transport(default,null) : EndpointTransport = socket;
+    public var framed(default,null) : Bool = false;
+    public var buffered(default,null) : Bool = false;
+
+    public var numIterations(default,null) : Int = 1;
+    public var numThreads(default,null) : Int = 1;
+    public var skipSpeedTest(default,null) : Bool = false;
+
+
+    public function new() {
+        #if sys
+        try {
+              ParseArgs();
+        } catch (e : String) {
+            trace(GetHelp());
+            throw e;
+        }
+        #else
+        trace("WN: Platform does not support program arguments, using defaults.");
+        #end
+    }
+
+    #if sys
+
+    private static function GetHelp() : String {
+        var sProg = Path.withoutDirectory( Sys.executablePath());
+        return "\n"
+            +sProg+"  [client|server]  [options]\n"
+            +"\n"
+            +"Modus: Either client or server, the default is client.\n"
+            +"\n"
+            +"Common options:\n"
+            +"  -h [ --help ]               produce help message\n"
+            +"  --port arg (=9090)          Port number to listen / connect to\n"
+            /* not supported yet
+            +"  --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)\n"
             +"  --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)\n"
-			*/
-			+"  --protocol arg (=binary)    protocol: binary, compact, json\n"
-			/* not supported yet
-			+"  --ssl                       Encrypted Transport using SSL\n"
-			*/
-			+"\n"
-			+"Server only options:\n"
+            */
+            +"  --protocol arg (=binary)    protocol: binary, compact, json\n"
+            /* not supported yet
+            +"  --ssl                       Encrypted Transport using SSL\n"
+            */
+            +"\n"
+            +"Server only options:\n"
             +"  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe\n"
-			/* not supported yet
-			+"  --processor-events          processor-events\n"
-			+"  --server-type arg (=simple) type of server, \"simple\", \"thread-pool\", \n"
-			+"                              \"threaded\", or \"nonblocking\"\n"
-			+"  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for \n"
-			+"                              thread-pool server type\n"
-			*/
-			+"\n"
-			+"Client only options:\n"
+            /* not supported yet
+            +"  --processor-events          processor-events\n"
+            +"  --server-type arg (=simple) type of server, \"simple\", \"thread-pool\", \n"
+            +"                              \"threaded\", or \"nonblocking\"\n"
+            +"  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for \n"
+            +"                              thread-pool server type\n"
+            */
+            +"\n"
+            +"Client only options:\n"
             +"  --host arg (=localhost)     Host to connect\n"
             +"  --transport arg (=sockets)  Transport: buffered, framed, http, evhttp\n"
-			/* not supported yet
+            /* not supported yet
             +"  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)\n"
-			*/
+            */
             +"  -n [ --testloops ] arg (=1) Number of Tests\n"
             +"  -t [ --threads ] arg (=1)   Number of Test threads\n"
             +"  --skip-speed-test           Skip the speed test\n"
-			+"\n"
-			+"All arguments are optional.\n"
-			;
-	}
-	
+            +"\n"
+            +"All arguments are optional.\n"
+            ;
+    }
 
-	private function ParseArgs() : Void {
-		
-		var args = Sys.args().copy();
-		if( (args == null) || (args.length <= 0)) {
-			server = false;
-			numThreads = 1;
-			return;
-		}
-		
-		var arg = args.shift();
-		if ( arg == "client") {
-			server = false;
-			numThreads = 1;
-		} 
-		else if ( arg == "server") {
-			server = true;
-			numThreads = 4;
-		} 
-		else if ( (arg == "-h") || (arg == "--help")) {
-			// -h [ --help ]               produce help message
-			Sys.println( GetHelp());
-			printHelpOnly = true;
-			return;
-		} 
-		else {
-			throw "First argument must be 'server' or 'client'";
-		}
 
-			
-		while( args.length > 0) {
-			arg = args.shift();
-			
-			if ( (arg == "-h") || (arg == "--help")) {
-				// -h [ --help ]               produce help message
-			    Sys.println( GetHelp());
-				printHelpOnly = true;
-				return;
-			} 
-			else if (arg == "--port") {		
-				// --port arg (=9090)          Port number to listen
-				arg = args.shift();
-				var tmp = Std.parseInt(arg);
-				if( tmp != null) {
-					port = tmp;
-				} else {
-					throw "Invalid port number "+arg;
-				}  
-			} 
-			else if (arg == "--domain-socket") {		
-				//   --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)
-				throw "domain sockets not supported yet";
-			} 
-			else if (arg == "--named-pipe") {		
-				//   --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)
-				throw "named pipes not supported yet";
-			} 
-			else if (arg == "--protocol") {		
-				// --protocol arg (=binary)    protocol: binary, compact, json
-				arg = args.shift();
-				if( arg == "binary") {
-					protocol = binary;
-				} else if( arg == "compact") {
-					throw "Compact protocol not supported yet";
-				} else if( arg == "json") {
-					protocol = json;
-				} else {
-					InvalidArg(arg);
-				}
-			}  
-			else if (arg == "--ssl") {		
-				// --ssl                       Encrypted Transport using SSL
-				throw "SSL not supported yet";
-			} 
-			else {
+    private function ParseArgs() : Void {
+
+        var args = Sys.args().copy();
+        if( (args == null) || (args.length <= 0)) {
+            server = false;
+            numThreads = 1;
+            return;
+        }
+
+        var arg = args.shift();
+        if ( arg == "client") {
+            server = false;
+            numThreads = 1;
+        }
+        else if ( arg == "server") {
+            server = true;
+            numThreads = 4;
+        }
+        else if ( (arg == "-h") || (arg == "--help")) {
+            // -h [ --help ]               produce help message
+            Sys.println( GetHelp());
+            printHelpOnly = true;
+            return;
+        }
+        else {
+            throw "First argument must be 'server' or 'client'";
+        }
+
+
+        while( args.length > 0) {
+            arg = args.shift();
+
+            if ( (arg == "-h") || (arg == "--help")) {
+                // -h [ --help ]               produce help message
+                Sys.println( GetHelp());
+                printHelpOnly = true;
+                return;
+            }
+            else if (arg == "--port") {
+                // --port arg (=9090)          Port number to listen
+                arg = args.shift();
+                var tmp = Std.parseInt(arg);
+                if( tmp != null) {
+                    port = tmp;
+                } else {
+                    throw "Invalid port number "+arg;
+                }
+            }
+            else if (arg == "--domain-socket") {
+                //   --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)
+                throw "domain sockets not supported yet";
+            }
+            else if (arg == "--named-pipe") {
+                //   --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)
+                throw "named pipes not supported yet";
+            }
+            else if (arg == "--protocol") {
+                // --protocol arg (=binary)    protocol: binary, compact, json
+                arg = args.shift();
+                if( arg == "binary") {
+                    protocol = binary;
+                } else if( arg == "compact") {
+                    throw "Compact protocol not supported yet";
+                } else if( arg == "json") {
+                    protocol = json;
+                } else {
+                    InvalidArg(arg);
+                }
+            }
+            else if (arg == "--ssl") {
+                // --ssl                       Encrypted Transport using SSL
+                throw "SSL not supported yet";
+            }
+            else {
                 //Server only options:
-				if( server) {
-					ParseServerArgument( arg, args);
-				} else {
-					ParseClientArgument( arg, args);
-				}
-			}
-		}
-	}
-	
+                if( server) {
+                    ParseServerArgument( arg, args);
+                } else {
+                    ParseClientArgument( arg, args);
+                }
+            }
+        }
+    }
 
-	private function ParseServerArgument( arg : String, args : Array<String>) : Void {
-		if (arg == "--transport") {
-			//  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe
-			arg = args.shift();
-			if( arg == "buffered") {
-				buffered = true;
-			} else if( arg == "framed") {
-				framed = true;
-			} else if( arg == "http") {
-				transport = http;
-			} else if( arg == "anonpipe") {
-				throw "Anon pipes transport not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if (arg == "--processor-events") {
-			throw "Processor events not supported yet";
-		}
-		else if (arg == "--server-type") {
-			//  --server-type arg (=simple) type of server, 
-			// one of "simple", "thread-pool", "threaded", "nonblocking"
-			arg = args.shift();
-			if( arg == "simple") {
-				servertype = simple;
-			} else if( arg == "thread-pool") {
-				throw arg+" server not supported yet";
-			} else if( arg == "threaded") {
-				throw arg+" server not supported yet";
-			} else if( arg == "nonblocking") {
-				throw arg+" server not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if ((arg == "-n") || (arg == "--workers")) {
-			//  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for 
-			//                              thread-pool server type
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numThreads = tmp;
-			} else{
-				throw "Invalid number "+arg;
-			} 
-		}
-		else {
-			InvalidArg(arg);
-		}
-	}
-	
 
-	private function ParseClientArgument( arg : String, args : Array<String>) : Void {
-		if (arg == "--host") {
+    private function ParseServerArgument( arg : String, args : Array<String>) : Void {
+        if (arg == "--transport") {
+            //  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe
+            arg = args.shift();
+            if( arg == "buffered") {
+                buffered = true;
+            } else if( arg == "framed") {
+                framed = true;
+            } else if( arg == "http") {
+                transport = http;
+            } else if( arg == "anonpipe") {
+                throw "Anon pipes transport not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if (arg == "--processor-events") {
+            throw "Processor events not supported yet";
+        }
+        else if (arg == "--server-type") {
+            //  --server-type arg (=simple) type of server,
+            // one of "simple", "thread-pool", "threaded", "nonblocking"
+            arg = args.shift();
+            if( arg == "simple") {
+                servertype = simple;
+            } else if( arg == "thread-pool") {
+                throw arg+" server not supported yet";
+            } else if( arg == "threaded") {
+                throw arg+" server not supported yet";
+            } else if( arg == "nonblocking") {
+                throw arg+" server not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if ((arg == "-n") || (arg == "--workers")) {
+            //  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for
+            //                              thread-pool server type
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numThreads = tmp;
+            } else{
+                throw "Invalid number "+arg;
+            }
+        }
+        else {
+            InvalidArg(arg);
+        }
+    }
+
+
+    private function ParseClientArgument( arg : String, args : Array<String>) : Void {
+        if (arg == "--host") {
             //  --host arg (=localhost)     Host to connect
-			host = args.shift();
-		}
-		else if (arg == "--transport") {
+            host = args.shift();
+        }
+        else if (arg == "--transport") {
             //  --transport arg (=sockets)  Transport: buffered, framed, http, evhttp
-			arg = args.shift();
-			if( arg == "buffered") {
-				buffered = true;
-			} else if( arg == "framed") {
-				framed = true;
-			} else if( arg == "http") {
-				transport = http;
-			} else if( arg == "evhttp") {
-				throw "evhttp transport not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if (arg == "--anon-pipes") {
-			//  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)
-			throw "Anon pipes transport not supported yet";
-		}
-		else if ((arg == "-n") || (arg == "--testloops")) {
-			//  -n [ --testloops ] arg (=1) Number of Tests
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numIterations = tmp;
-			} else {
-				throw "Invalid number "+arg;
-			}  
-		}
-		else if ((arg == "-t") || (arg == "--threads")) {
-			//  -t [ --threads ] arg (=1)   Number of Test threads
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numThreads = tmp;
-			} else {
-				throw "Invalid number "+arg;
-			}  
-		}
-		else if (arg == "--skip-speed-test") {
-			//  --skip-speed-test  			Skip the speed test
-			skipSpeedTest = true;
-		}			
-		else {
-			InvalidArg(arg);
-		}
-	}
+            arg = args.shift();
+            if( arg == "buffered") {
+                buffered = true;
+            } else if( arg == "framed") {
+                framed = true;
+            } else if( arg == "http") {
+                transport = http;
+            } else if( arg == "evhttp") {
+                throw "evhttp transport not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if (arg == "--anon-pipes") {
+            //  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)
+            throw "Anon pipes transport not supported yet";
+        }
+        else if ((arg == "-n") || (arg == "--testloops")) {
+            //  -n [ --testloops ] arg (=1) Number of Tests
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numIterations = tmp;
+            } else {
+                throw "Invalid number "+arg;
+            }
+        }
+        else if ((arg == "-t") || (arg == "--threads")) {
+            //  -t [ --threads ] arg (=1)   Number of Test threads
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numThreads = tmp;
+            } else {
+                throw "Invalid number "+arg;
+            }
+        }
+        else if (arg == "--skip-speed-test") {
+            //  --skip-speed-test              Skip the speed test
+            skipSpeedTest = true;
+        }
+        else {
+            InvalidArg(arg);
+        }
+    }
 
-	
-	#end
-		
-		
-	private function InvalidArg( arg : String) : Void {
-		throw 'Invalid argument $arg';
-	}
+
+    #end
+
+
+    private function InvalidArg( arg : String) : Void {
+        throw 'Invalid argument $arg';
+    }
 }
diff --git a/test/haxe/src/Main.hx b/test/haxe/src/Main.hx
index 6d80c21..30c04a6 100644
--- a/test/haxe/src/Main.hx
+++ b/test/haxe/src/Main.hx
@@ -17,7 +17,7 @@
  * under the License.
  */
 
- 
+
 package;
 
 import org.apache.thrift.*;
@@ -30,22 +30,22 @@
 
 class Main
 {
-	static function main() {
-		try {
-			var args = new Arguments();
-			
-			if( args.printHelpOnly) 
-				return;
-			
-			if (args.server)
-				TestServer.Execute(args);
-			else 
-				TestClient.Execute(args);
-			
-			trace("Completed.");
-		} catch (e : String) {
-			trace(e);
-		}
-	}
+    static function main() {
+        try {
+            var args = new Arguments();
+
+            if( args.printHelpOnly)
+                return;
+
+            if (args.server)
+                TestServer.Execute(args);
+            else
+                TestClient.Execute(args);
+
+            trace("Completed.");
+        } catch (e : String) {
+            trace(e);
+        }
+    }
 
 }
diff --git a/test/haxe/src/TestClient.hx b/test/haxe/src/TestClient.hx
index 3c98e6a..3f9158e 100644
--- a/test/haxe/src/TestClient.hx
+++ b/test/haxe/src/TestClient.hx
@@ -43,758 +43,758 @@
 
 
 class TestResults {
-	private var successCnt : Int = 0;
-	private var errorCnt : Int = 0;
-	private var failedTests : String = "";
-	private var print_direct : Bool = false;
-	
-	public static var EXITCODE_SUCCESS            = 0x00;  // no errors bits set
-	//
-	public static var EXITCODE_FAILBIT_BASETYPES  = 0x01;
-	public static var EXITCODE_FAILBIT_STRUCTS    = 0x02;
-	public static var EXITCODE_FAILBIT_CONTAINERS = 0x04;
-	public static var EXITCODE_FAILBIT_EXCEPTIONS = 0x08;
-	//
-	public static var EXITCODE_ALL_FAILBITS 	  = 0x0F;
-	//
-	private var testsExecuted : Int = 0;
-	private var testsFailed : Int = 0;
-	private var currentTest : Int = 0;
+    private var successCnt : Int = 0;
+    private var errorCnt : Int = 0;
+    private var failedTests : String = "";
+    private var print_direct : Bool = false;
 
-	
-	public function new(direct : Bool) {
-		print_direct = direct;
-	}
-	
-	public function StartTestGroup( groupBit : Int) : Void {
-		currentTest = groupBit;
-		testsExecuted |= groupBit;
-	}
-	
-	public function Expect( expr : Bool, msg : String) : Void {
-		if ( expr) {
-			++successCnt;
-		} else {
-			++errorCnt;
-			testsFailed |= currentTest;
-			failedTests += "\n  " + msg;
-			if( print_direct) {
-				trace('FAIL: $msg');
-			}
-		}
-	}
+    public static var EXITCODE_SUCCESS            = 0x00;  // no errors bits set
+    //
+    public static var EXITCODE_FAILBIT_BASETYPES  = 0x01;
+    public static var EXITCODE_FAILBIT_STRUCTS    = 0x02;
+    public static var EXITCODE_FAILBIT_CONTAINERS = 0x04;
+    public static var EXITCODE_FAILBIT_EXCEPTIONS = 0x08;
+    //
+    public static var EXITCODE_ALL_FAILBITS       = 0x0F;
+    //
+    private var testsExecuted : Int = 0;
+    private var testsFailed : Int = 0;
+    private var currentTest : Int = 0;
 
-	public function CalculateExitCode() : Int {
-		var notExecuted : Int = EXITCODE_ALL_FAILBITS & (~testsExecuted);
-		return testsFailed | notExecuted;
-	}
 
-	public function PrintSummary() : Void {
-		var total = successCnt + errorCnt;
-		var sp = (100 * successCnt) / total;
-		var ep = (100 * errorCnt) / total;
-		
-		trace('===========================');
-		trace('Tests executed    $total');
-		trace('Tests succeeded   $successCnt ($sp%)');
-		trace('Tests failed      $errorCnt ($ep%)');
-		if ( errorCnt > 0)
-		{
-			trace('===========================');
-  			trace('FAILED TESTS: $failedTests');
-		}
-		trace('===========================');
-	}
+    public function new(direct : Bool) {
+        print_direct = direct;
+    }
+
+    public function StartTestGroup( groupBit : Int) : Void {
+        currentTest = groupBit;
+        testsExecuted |= groupBit;
+    }
+
+    public function Expect( expr : Bool, msg : String) : Void {
+        if ( expr) {
+            ++successCnt;
+        } else {
+            ++errorCnt;
+            testsFailed |= currentTest;
+            failedTests += "\n  " + msg;
+            if( print_direct) {
+                trace('FAIL: $msg');
+            }
+        }
+    }
+
+    public function CalculateExitCode() : Int {
+        var notExecuted : Int = EXITCODE_ALL_FAILBITS & (~testsExecuted);
+        return testsFailed | notExecuted;
+    }
+
+    public function PrintSummary() : Void {
+        var total = successCnt + errorCnt;
+        var sp = (100 * successCnt) / total;
+        var ep = (100 * errorCnt) / total;
+
+        trace('===========================');
+        trace('Tests executed    $total');
+        trace('Tests succeeded   $successCnt ($sp%)');
+        trace('Tests failed      $errorCnt ($ep%)');
+        if ( errorCnt > 0)
+        {
+            trace('===========================');
+              trace('FAILED TESTS: $failedTests');
+        }
+        trace('===========================');
+    }
 }
 
 
 class TestClient {
 
-	public static function Execute(args : Arguments) :  Void
-	{
-		var exitCode = 0xFF;
-		try
-		{
-			var difft = Timer.stamp();
-	
-			if( args.numThreads > 1) {
-				var threads = new List<Thread>();
-				for( test in 0 ... args.numThreads) {
-					threads.add( StartThread( args));
-				} 
-				exitCode = 0;
-				for( thread in threads) {
-					exitCode |= Thread.readMessage(true);
-				}
-			} else {
-				var rslt = new TestResults(true);
-				RunClient(args,rslt);
-				rslt.PrintSummary();
-				exitCode = rslt.CalculateExitCode();
-			}
+    public static function Execute(args : Arguments) :  Void
+    {
+        var exitCode = 0xFF;
+        try
+        {
+            var difft = Timer.stamp();
 
-			difft = Timer.stamp() - difft;
-			trace('total test time: $difft seconds');
-		}
-		catch (e : TException)
-		{
-			trace('$e');
-			exitCode = 0xFF;
-		}
-		catch (e : Dynamic)
-		{
-			trace('$e');
-			exitCode = 0xFF;
-		}
-	
-		#if sys
-		Sys.exit( exitCode);
-		#end
-	}
+            if( args.numThreads > 1) {
+                var threads = new List<Thread>();
+                for( test in 0 ... args.numThreads) {
+                    threads.add( StartThread( args));
+                }
+                exitCode = 0;
+                for( thread in threads) {
+                    exitCode |= Thread.readMessage(true);
+                }
+            } else {
+                var rslt = new TestResults(true);
+                RunClient(args,rslt);
+                rslt.PrintSummary();
+                exitCode = rslt.CalculateExitCode();
+            }
 
-	
-	private static function StartThread(args : Arguments) : Thread {
-		var thread = Thread.create(
-			function() : Void {
-				var rslt = new TestResults(false);
-				var main : Thread = Thread.readMessage(true);
-				try 
-				{
-					RunClient(args,rslt);
-				}
-				catch (e : TException)
-				{
-					rslt.Expect( false, '$e');
-					trace('$e');
-				}
-				catch (e : Dynamic)
-				{
-					rslt.Expect( false, '$e');
-					trace('$e');
-				}					
-				main.sendMessage( rslt.CalculateExitCode());
-			});
-		
-		thread.sendMessage(Thread.current());
-		return thread;
-	}
+            difft = Timer.stamp() - difft;
+            trace('total test time: $difft seconds');
+        }
+        catch (e : TException)
+        {
+            trace('$e');
+            exitCode = 0xFF;
+        }
+        catch (e : Dynamic)
+        {
+            trace('$e');
+            exitCode = 0xFF;
+        }
 
-	
-	public static function RunClient(args : Arguments, rslt : TestResults)
-	{
-		var transport : TTransport = null;
-		switch (args.transport)
-		{
-			case socket:
-				transport = new TSocket(args.host, args.port);
-			case http:
-				transport = new THttpClient(args.host);
-			default:
-				throw "Unhandled transport";
-		}
+        #if sys
+        Sys.exit( exitCode);
+        #end
+    }
 
-		// optional: layered transport
-		if ( args.framed) {
-			trace("- framed transport");
-			transport = new TFramedTransport(transport);
-		} 
-		if ( args.buffered) {
-			trace("- buffered transport");
-			throw "TBufferedTransport not implemented yet";
-			//transport = new TBufferedTransport(transport);
-		}
 
-		// protocol
-		var protocol : TProtocol = null;
-		switch( args.protocol)
-		{
-		case binary:
-			trace("- binary protocol");
-			protocol = new TBinaryProtocol(transport);
-		case json:
-			trace("- json protocol");
-			protocol = new TJSONProtocol(transport);
-		default:
-			throw "Unhandled protocol";
-		}
+    private static function StartThread(args : Arguments) : Thread {
+        var thread = Thread.create(
+            function() : Void {
+                var rslt = new TestResults(false);
+                var main : Thread = Thread.readMessage(true);
+                try
+                {
+                    RunClient(args,rslt);
+                }
+                catch (e : TException)
+                {
+                    rslt.Expect( false, '$e');
+                    trace('$e');
+                }
+                catch (e : Dynamic)
+                {
+                    rslt.Expect( false, '$e');
+                    trace('$e');
+                }
+                main.sendMessage( rslt.CalculateExitCode());
+            });
 
+        thread.sendMessage(Thread.current());
+        return thread;
+    }
 
-		// run the test code
-		HaxeBasicsTest( args, rslt);
-		for( i in 0 ... args.numIterations) {
-			ClientTest( transport, protocol, args, rslt);
-		}
-	}
 
+    public static function RunClient(args : Arguments, rslt : TestResults)
+    {
+        var transport : TTransport = null;
+        switch (args.transport)
+        {
+            case socket:
+                transport = new TSocket(args.host, args.port);
+            case http:
+                transport = new THttpClient(args.host);
+            default:
+                throw "Unhandled transport";
+        }
 
-	public static function HaxeBasicsTest( args : Arguments, rslt : TestResults) : Void
-	{
-		// We need to test a few basic things used in the ClientTest
-		// Anything else beyond this scope should go into /lib/haxe/ instead
-		rslt.StartTestGroup( 0);
-		
-		var map32 = new IntMap<Int32>();
-		var map64 = new Int64Map<Int32>();
+        // optional: layered transport
+        if ( args.framed) {
+            trace("- framed transport");
+            transport = new TFramedTransport(transport);
+        }
+        if ( args.buffered) {
+            trace("- buffered transport");
+            throw "TBufferedTransport not implemented yet";
+            //transport = new TBufferedTransport(transport);
+        }
 
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #1");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #2");
-		rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #3");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #4");
-		
-		map32.set( 42, 815);
-		map64.set( Int64.make(0,42), 815);
-		map32.set( -517, 23);
-		map64.set( Int64.make(-5,17), 23);
-		map32.set( 0, -123);
-		map64.set( Int64.make(0,0), -123);
+        // protocol
+        var protocol : TProtocol = null;
+        switch( args.protocol)
+        {
+        case binary:
+            trace("- binary protocol");
+            protocol = new TBinaryProtocol(transport);
+        case json:
+            trace("- json protocol");
+            protocol = new TJSONProtocol(transport);
+        default:
+            throw "Unhandled protocol";
+        }
 
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #12");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #13");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #14");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #15");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #16");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #Int64.make(-5,17)");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #18");
-		rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #19");
-		rslt.Expect( map32.remove( -517) == map64.remove( Int64.make(-5,17)), "Int64Map<Int32> Test #20");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #21");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #22");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #23");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #24");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #25");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #26");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #27");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #28");
 
-		map32.set( 42, 1);
-		map64.set( Int64.make(0,42), 1);
-		map32.set( -517, -2);
-		map64.set( Int64.make(-5,17), -2);
-		map32.set( 0, 3);
-		map64.set( Int64.make(0,0), 3);
+        // run the test code
+        HaxeBasicsTest( args, rslt);
+        for( i in 0 ... args.numIterations) {
+            ClientTest( transport, protocol, args, rslt);
+        }
+    }
 
-		var c32 = 0;
-		for (key in map32.keys()) {
-			++c32;
-		}
-		var c64 = 0;
-		for (key in map64.keys()) {
-			++c64;
-		}
-		rslt.Expect( c32 == c64, "Int64Map<Int32> Test #30");
 
-		var s32 = map32.toString();
-		var s64 = map64.toString();
-		trace("Int64Map<Int32>.toString(): " + ' ("$s32" == "$s64")');
+    public static function HaxeBasicsTest( args : Arguments, rslt : TestResults) : Void
+    {
+        // We need to test a few basic things used in the ClientTest
+        // Anything else beyond this scope should go into /lib/haxe/ instead
+        rslt.StartTestGroup( 0);
 
-		map32.remove( 42);
-		map64.remove( Int64.make(0,42));
-		map32.remove( -517);
-		map64.remove( Int64.make(-5,17));
-		map32.remove( 0);
-		map64.remove( Int64.make(0,0));
-		
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #90");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #91");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #92");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #93");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #94");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #95");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #96");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #97");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #98");
-	}
+        var map32 = new IntMap<Int32>();
+        var map64 = new Int64Map<Int32>();
 
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #1");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #2");
+        rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #3");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #4");
 
-	public static function ClientTest( transport : TTransport, protocol : TProtocol, 
-									   args : Arguments, rslt : TestResults) : Void
-	{
-		var client = new ThriftTestImpl(protocol,protocol);
-		try
-		{
-			if (!transport.isOpen())
-			{
-				transport.open();
-			}
-		}
-		catch (e : TException)
-		{
-			trace('$e');
-			return;
-		}
-		catch (e : Dynamic)
-		{
-			trace('$e');
-			return;
-		}
+        map32.set( 42, 815);
+        map64.set( Int64.make(0,42), 815);
+        map32.set( -517, 23);
+        map64.set( Int64.make(-5,17), 23);
+        map32.set( 0, -123);
+        map64.set( Int64.make(0,0), -123);
 
-		var start = Date.now();
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #12");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #13");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #14");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #15");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #16");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #Int64.make(-5,17)");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #18");
+        rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #19");
+        rslt.Expect( map32.remove( -517) == map64.remove( Int64.make(-5,17)), "Int64Map<Int32> Test #20");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #21");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #22");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #23");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #24");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #25");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #26");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #27");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #28");
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_EXCEPTIONS);
-	
-		// if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
-		trace('testException("Xception")');
-		try {
-			client.testException("Xception");
-			rslt.Expect( false, 'testException("Xception") should throw');
-		}
-		catch (e : Xception)
-		{
-			rslt.Expect( e.message == "Xception", 'testException("Xception")  -  e.message == "Xception"');
-			rslt.Expect( e.errorCode == 1001, 'testException("Xception")  -  e.errorCode == 1001');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("Xception")  -  $e');
-		} 
-	
-		// if arg == "TException" throw TException
-		trace('testException("TException")');
-		try {
-			client.testException("TException");
-			rslt.Expect( false, 'testException("TException") should throw');
-		}
-		catch (e : TException)
-		{
-			rslt.Expect( true, 'testException("TException")  -  $e');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("TException")  -  $e');
-		} 
-	
-		// else do not throw anything
-		trace('testException("bla")');
-		try {
-			client.testException("bla");
-			rslt.Expect( true, 'testException("bla") should not throw');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("bla")  -  $e');
-		} 
-			
-		
+        map32.set( 42, 1);
+        map64.set( Int64.make(0,42), 1);
+        map32.set( -517, -2);
+        map64.set( Int64.make(-5,17), -2);
+        map32.set( 0, 3);
+        map64.set( Int64.make(0,0), 3);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
-		
-		trace('testVoid()');
-		client.testVoid();
-		trace(' = void');
-		rslt.Expect(true,"testVoid()");  // bump counter
+        var c32 = 0;
+        for (key in map32.keys()) {
+            ++c32;
+        }
+        var c64 = 0;
+        for (key in map64.keys()) {
+            ++c64;
+        }
+        rslt.Expect( c32 == c64, "Int64Map<Int32> Test #30");
 
-		trace('testString("Test")');
-		var s = client.testString("Test");
-		trace(' = "$s"');
-		rslt.Expect(s == "Test", '$s == "Test"');
+        var s32 = map32.toString();
+        var s64 = map64.toString();
+        trace("Int64Map<Int32>.toString(): " + ' ("$s32" == "$s64")');
 
-		trace('testByte(1)');
-		var i8 = client.testByte(1);
-		trace(' = $i8');
-		rslt.Expect(i8 == 1, '$i8 == 1');
+        map32.remove( 42);
+        map64.remove( Int64.make(0,42));
+        map32.remove( -517);
+        map64.remove( Int64.make(-5,17));
+        map32.remove( 0);
+        map64.remove( Int64.make(0,0));
 
-		trace('testI32(-1)');
-		var i32 = client.testI32(-1);
-		trace(' = $i32');
-		rslt.Expect(i32 == -1, '$i32 == -1');
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #90");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #91");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #92");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #93");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #94");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #95");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #96");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #97");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #98");
+    }
 
-		trace('testI64(-34359738368)');
-		var i64 = client.testI64( Int64.make( 0xFFFFFFF8, 0x00000000)); // -34359738368
-		trace(' = $i64');
-		rslt.Expect( Int64.compare( i64, Int64.make( 0xFFFFFFF8, 0x00000000)) == 0, 
-		             Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0xFFFFFFF8, 0x00000000)));
 
-		// edge case: the largest negative Int64 has no positive Int64 equivalent
-		trace('testI64(-9223372036854775808)');
-		i64 = client.testI64( Int64.make( 0x80000000, 0x00000000)); // -9223372036854775808
-		trace(' = $i64');
-		rslt.Expect( Int64.compare( i64, Int64.make( 0x80000000, 0x00000000)) == 0, 
-		             Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0x80000000, 0x00000000)));
+    public static function ClientTest( transport : TTransport, protocol : TProtocol,
+                                       args : Arguments, rslt : TestResults) : Void
+    {
+        var client = new ThriftTestImpl(protocol,protocol);
+        try
+        {
+            if (!transport.isOpen())
+            {
+                transport.open();
+            }
+        }
+        catch (e : TException)
+        {
+            trace('$e');
+            return;
+        }
+        catch (e : Dynamic)
+        {
+            trace('$e');
+            return;
+        }
 
-		trace('testDouble(5.325098235)');
-		var dub = client.testDouble(5.325098235);
-		trace(' = $dub');
-		rslt.Expect(dub == 5.325098235, '$dub == 5.325098235');
+        var start = Date.now();
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_EXCEPTIONS);
+
+        // if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
+        trace('testException("Xception")');
+        try {
+            client.testException("Xception");
+            rslt.Expect( false, 'testException("Xception") should throw');
+        }
+        catch (e : Xception)
+        {
+            rslt.Expect( e.message == "Xception", 'testException("Xception")  -  e.message == "Xception"');
+            rslt.Expect( e.errorCode == 1001, 'testException("Xception")  -  e.errorCode == 1001');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("Xception")  -  $e');
+        }
+
+        // if arg == "TException" throw TException
+        trace('testException("TException")');
+        try {
+            client.testException("TException");
+            rslt.Expect( false, 'testException("TException") should throw');
+        }
+        catch (e : TException)
+        {
+            rslt.Expect( true, 'testException("TException")  -  $e');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("TException")  -  $e');
+        }
+
+        // else do not throw anything
+        trace('testException("bla")');
+        try {
+            client.testException("bla");
+            rslt.Expect( true, 'testException("bla") should not throw');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("bla")  -  $e');
+        }
+
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
+
+        trace('testVoid()');
+        client.testVoid();
+        trace(' = void');
+        rslt.Expect(true,"testVoid()");  // bump counter
+
+        trace('testString("Test")');
+        var s = client.testString("Test");
+        trace(' = "$s"');
+        rslt.Expect(s == "Test", '$s == "Test"');
+
+        trace('testByte(1)');
+        var i8 = client.testByte(1);
+        trace(' = $i8');
+        rslt.Expect(i8 == 1, '$i8 == 1');
+
+        trace('testI32(-1)');
+        var i32 = client.testI32(-1);
+        trace(' = $i32');
+        rslt.Expect(i32 == -1, '$i32 == -1');
+
+        trace('testI64(-34359738368)');
+        var i64 = client.testI64( Int64.make( 0xFFFFFFF8, 0x00000000)); // -34359738368
+        trace(' = $i64');
+        rslt.Expect( Int64.compare( i64, Int64.make( 0xFFFFFFF8, 0x00000000)) == 0,
+                     Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0xFFFFFFF8, 0x00000000)));
+
+        // edge case: the largest negative Int64 has no positive Int64 equivalent
+        trace('testI64(-9223372036854775808)');
+        i64 = client.testI64( Int64.make( 0x80000000, 0x00000000)); // -9223372036854775808
+        trace(' = $i64');
+        rslt.Expect( Int64.compare( i64, Int64.make( 0x80000000, 0x00000000)) == 0,
+                     Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0x80000000, 0x00000000)));
+
+        trace('testDouble(5.325098235)');
+        var dub = client.testDouble(5.325098235);
+        trace(' = $dub');
+        rslt.Expect(dub == 5.325098235, '$dub == 5.325098235');
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
+
+        trace('testStruct({"Zero", 1, -3, -5})');
+        var o = new Xtruct();
+        o.string_thing = "Zero";
+        o.byte_thing = 1;
+        o.i32_thing = -3;
+        o.i64_thing = Int64.make(0,-5);
+        var i = client.testStruct(o);
+        trace(' = {"' + i.string_thing + '", ' + i.byte_thing +', '
+                      + i.i32_thing +', '+ Int64.toStr(i.i64_thing) + '}');
+        rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
+        rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+
+        trace('testNest({1, {\"Zero\", 1, -3, -5}, 5})');
+        var o2 = new Xtruct2();
+        o2.byte_thing = 1;
+        o2.struct_thing = o;
+        o2.i32_thing = 5;
+        var i2 = client.testNest(o2);
+        i = i2.struct_thing;
+        trace(" = {" + i2.byte_thing + ", {\"" + i.string_thing + "\", "
+              + i.byte_thing + ", " + i.i32_thing + ", " + Int64.toStr(i.i64_thing) + "}, "
+              + i2.i32_thing + "}");
+        rslt.Expect( i2.byte_thing == o2.byte_thing, "i2.byte_thing == o2.byte_thing");
+        rslt.Expect( i2.i32_thing == o2.i32_thing, "i2.i32_thing == o2.i32_thing");
+        rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
+        rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i32_thing == o.i32_thing");
+        rslt.Expect( Int64.compare( i.i64_thing, o.i64_thing) == 0, "i.i64_thing == o.i64_thing");
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
+
+        var mapout = new IntMap< haxe.Int32>();
+        for ( j in 0 ... 5)
+        {
+            mapout.set(j, j - 10);
+        }
+        trace("testMap({");
+        var first : Bool = true;
+        for( key in mapout.keys())
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(key + " => " + mapout.get(key));
+        }
+        trace("})");
 
-		
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
-		
-		trace('testStruct({"Zero", 1, -3, -5})');
-		var o = new Xtruct();
-		o.string_thing = "Zero";
-		o.byte_thing = 1;
-		o.i32_thing = -3;
-		o.i64_thing = Int64.make(0,-5);
-		var i = client.testStruct(o);
-		trace(' = {"' + i.string_thing + '", ' + i.byte_thing +', ' 
-					  + i.i32_thing +', '+ Int64.toStr(i.i64_thing) + '}');
-		rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
-		rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+        var mapin = client.testMap(mapout);
 
-		trace('testNest({1, {\"Zero\", 1, -3, -5}, 5})');
-		var o2 = new Xtruct2();
-		o2.byte_thing = 1;
-		o2.struct_thing = o;
-		o2.i32_thing = 5;
-		var i2 = client.testNest(o2);
-		i = i2.struct_thing;
-		trace(" = {" + i2.byte_thing + ", {\"" + i.string_thing + "\", " 
-			  + i.byte_thing + ", " + i.i32_thing + ", " + Int64.toStr(i.i64_thing) + "}, " 
-			  + i2.i32_thing + "}");
-		rslt.Expect( i2.byte_thing == o2.byte_thing, "i2.byte_thing == o2.byte_thing");
-		rslt.Expect( i2.i32_thing == o2.i32_thing, "i2.i32_thing == o2.i32_thing");
-		rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
-		rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i32_thing == o.i32_thing");
-		rslt.Expect( Int64.compare( i.i64_thing, o.i64_thing) == 0, "i.i64_thing == o.i64_thing");
+        trace(" = {");
+        first = true;
+        for( key in mapin.keys())
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(key + " => " + mapin.get(key));
+            rslt.Expect( mapin.get(key) == mapout.get(key), ' mapin.get($key) == mapout.get($key)');
+        }
+        trace("}");
+        for( key in mapout.keys())
+        {
+            rslt.Expect(mapin.exists(key), 'mapin.exists($key)');
+        }
 
-		
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
-		
-		var mapout = new IntMap< haxe.Int32>();
-		for ( j in 0 ... 5)
-		{
-			mapout.set(j, j - 10);
-		}
-		trace("testMap({");
-		var first : Bool = true;
-		for( key in mapout.keys())
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(key + " => " + mapout.get(key));
-		}
-		trace("})");
+        var listout = new List<Int>();
+        for (j in -2 ... 3)
+        {
+            listout.add(j);
+        }
+        trace("testList({");
+        first = true;
+        for( j in listout)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("})");
 
-		var mapin = client.testMap(mapout);
+        var listin = client.testList(listout);
 
-		trace(" = {");
-		first = true;
-		for( key in mapin.keys())
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(key + " => " + mapin.get(key));
-			rslt.Expect( mapin.get(key) == mapout.get(key), ' mapin.get($key) == mapout.get($key)');
-		}
-		trace("}");
-		for( key in mapout.keys())
-		{
-			rslt.Expect(mapin.exists(key), 'mapin.exists($key)');
-		}
+        trace(" = {");
+        first = true;
+        for( j in listin)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("}");
 
-		var listout = new List<Int>();
-		for (j in -2 ... 3)
-		{
-			listout.add(j);
-		}
-		trace("testList({");
-		first = true;
-		for( j in listout)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("})");
+        rslt.Expect(listin.length == listout.length, "listin.length == listout.length");
+        var literout = listout.iterator();
+        var literin = listin.iterator();
+        while( literin.hasNext()) {
+            rslt.Expect(literin.next() == literout.next(), "literin[i] == literout[i]");
+        }
 
-		var listin = client.testList(listout);
+        //set
+        var setout = new IntSet();
+        for (j in -2 ... 3)
+        {
+            setout.add(j);
+        }
+        trace("testSet({");
+        first = true;
+        for( j in setout)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("})");
 
-		trace(" = {");
-		first = true;
-		for( j in listin)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("}");
+        var setin = client.testSet(setout);
 
-		rslt.Expect(listin.length == listout.length, "listin.length == listout.length");
-		var literout = listout.iterator();
-		var literin = listin.iterator();
-		while( literin.hasNext()) {
-			rslt.Expect(literin.next() == literout.next(), "literin[i] == literout[i]");
-		}
-	
-		//set
-		var setout = new IntSet();
-		for (j in -2 ... 3)
-		{
-			setout.add(j);
-		}
-		trace("testSet({");
-		first = true;
-		for( j in setout)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("})");
+        trace(" = {");
+        first = true;
+        for( j in setin)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+            rslt.Expect(setout.contains(j), 'setout.contains($j)');
+        }
+        trace("}");
+        rslt.Expect(setin.size == setout.size, "setin.length == setout.length");
 
-		var setin = client.testSet(setout);
 
-		trace(" = {");
-		first = true;
-		for( j in setin)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-			rslt.Expect(setout.contains(j), 'setout.contains($j)');
-		}
-		trace("}");
-		rslt.Expect(setin.size == setout.size, "setin.length == setout.length");
-	
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
+        trace("testEnum(ONE)");
+        var ret = client.testEnum(Numberz.ONE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.ONE, '$ret == Numberz.ONE');
 
-		trace("testEnum(ONE)");
-		var ret = client.testEnum(Numberz.ONE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.ONE, '$ret == Numberz.ONE');
+        trace("testEnum(TWO)");
+        ret = client.testEnum(Numberz.TWO);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.TWO, '$ret == Numberz.TWO');
 
-		trace("testEnum(TWO)");
-		ret = client.testEnum(Numberz.TWO);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.TWO, '$ret == Numberz.TWO');
+        trace("testEnum(THREE)");
+        ret = client.testEnum(Numberz.THREE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.THREE, '$ret == Numberz.THREE');
 
-		trace("testEnum(THREE)");
-		ret = client.testEnum(Numberz.THREE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.THREE, '$ret == Numberz.THREE');
+        trace("testEnum(FIVE)");
+        ret = client.testEnum(Numberz.FIVE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.FIVE, '$ret == Numberz.FIVE');
 
-		trace("testEnum(FIVE)");
-		ret = client.testEnum(Numberz.FIVE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.FIVE, '$ret == Numberz.FIVE');
+        trace("testEnum(EIGHT)");
+        ret = client.testEnum(Numberz.EIGHT);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.EIGHT, '$ret == Numberz.EIGHT');
 
-		trace("testEnum(EIGHT)");
-		ret = client.testEnum(Numberz.EIGHT);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.EIGHT, '$ret == Numberz.EIGHT');
+        trace("testTypedef(309858235082523)");
+        var uid = client.testTypedef( Int64.make( 0x119D0, 0x7E08671B));  // 309858235082523
+        trace(" = " + uid);
+        rslt.Expect( Int64.compare( uid, Int64.make( 0x119D0, 0x7E08671B)) == 0,
+                     Int64.toStr(uid)+" == "+Int64.toStr(Int64.make( 0x119D0, 0x7E08671B)));
 
-		trace("testTypedef(309858235082523)");
-		var uid = client.testTypedef( Int64.make( 0x119D0, 0x7E08671B));  // 309858235082523
-		trace(" = " + uid);
-		rslt.Expect( Int64.compare( uid, Int64.make( 0x119D0, 0x7E08671B)) == 0,
-		             Int64.toStr(uid)+" == "+Int64.toStr(Int64.make( 0x119D0, 0x7E08671B)));
 
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
+        trace("testMapMap(1)");
+        var mm = client.testMapMap(1);
+        trace(" = {");
+        for( key in mm.keys())
+        {
+            trace(key + " => {");
+            var m2 = mm.get(key);
+            for( k2 in m2.keys())
+            {
+                trace(k2 + " => " + m2.get(k2) + ", ");
+            }
+            trace("}, ");
+        }
+        trace("}");
 
-		trace("testMapMap(1)");
-		var mm = client.testMapMap(1);
-		trace(" = {");
-		for( key in mm.keys())
-		{
-			trace(key + " => {");
-			var m2 = mm.get(key);
-			for( k2 in m2.keys())
-			{
-				trace(k2 + " => " + m2.get(k2) + ", ");
-			}
-			trace("}, ");
-		}
-		trace("}");
+        var pos = mm.get(4);
+        var neg = mm.get(-4);
+        rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)");
+        for (i in 0 ... 5) {
+            rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i');
+            rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i');
+         }
 
-		var pos = mm.get(4);
-		var neg = mm.get(-4);
-		rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)");
-		for (i in 0 ... 5) {
-			rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i');
-			rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i');
-	 	}
 
-			
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
 
-		var insane = new Insanity();
-		insane.userMap = new IntMap< Int64>();
-		insane.userMap.set( Numberz.FIVE, Int64.make(0,5000));
-		var truck = new Xtruct();
-		truck.string_thing = "Truck";
-		truck.byte_thing = 8;
-		truck.i32_thing = 8;
-		truck.i64_thing = Int64.make(0,8);
-		insane.xtructs = new List<Xtruct>();
-		insane.xtructs.add(truck);
-		trace("testInsanity()");
-		var whoa = client.testInsanity(insane);
-		trace(" = {");
-		for( key in whoa.keys())
-		{
-			var val = whoa.get(key);
-			trace(key + " => {");
+        var insane = new Insanity();
+        insane.userMap = new IntMap< Int64>();
+        insane.userMap.set( Numberz.FIVE, Int64.make(0,5000));
+        var truck = new Xtruct();
+        truck.string_thing = "Truck";
+        truck.byte_thing = 8;
+        truck.i32_thing = 8;
+        truck.i64_thing = Int64.make(0,8);
+        insane.xtructs = new List<Xtruct>();
+        insane.xtructs.add(truck);
+        trace("testInsanity()");
+        var whoa = client.testInsanity(insane);
+        trace(" = {");
+        for( key in whoa.keys())
+        {
+            var val = whoa.get(key);
+            trace(key + " => {");
 
-			for( k2 in val.keys())
-			{
-				var v2 = val.get(k2);
+            for( k2 in val.keys())
+            {
+                var v2 = val.get(k2);
 
-				trace(k2 + " => {");
-				var userMap = v2.userMap;
+                trace(k2 + " => {");
+                var userMap = v2.userMap;
 
-				trace("{");
-				if (userMap != null)
-				{
-					for( k3 in userMap.keys())
-					{
-						trace(k3 + " => " + userMap.get(k3) + ", ");
-					}
-				}
-				else
-				{
-					trace("null");
-				}
-				trace("}, ");
+                trace("{");
+                if (userMap != null)
+                {
+                    for( k3 in userMap.keys())
+                    {
+                        trace(k3 + " => " + userMap.get(k3) + ", ");
+                    }
+                }
+                else
+                {
+                    trace("null");
+                }
+                trace("}, ");
 
-				var xtructs = v2.xtructs;
+                var xtructs = v2.xtructs;
 
-				trace("{");
-				if (xtructs != null)
-				{
-					for( x in xtructs)
-					{
-						trace("{\"" + x.string_thing + "\", " 
-							  + x.byte_thing + ", " + x.i32_thing + ", " 
-							  + x.i32_thing + "}, ");
-					}
-				}
-				else
-				{
-					trace("null");
-				}
-				trace("}");
+                trace("{");
+                if (xtructs != null)
+                {
+                    for( x in xtructs)
+                    {
+                        trace("{\"" + x.string_thing + "\", "
+                              + x.byte_thing + ", " + x.i32_thing + ", "
+                              + x.i32_thing + "}, ");
+                    }
+                }
+                else
+                {
+                    trace("null");
+                }
+                trace("}");
 
-				trace("}, ");
-			}
-			trace("}, ");
-		}
-		trace("}");
+                trace("}, ");
+            }
+            trace("}, ");
+        }
+        trace("}");
 
 
-		var first_map = whoa.get(Int64.make(0,1));
-		var second_map = whoa.get(Int64.make(0,2));
-		rslt.Expect( (first_map != null) && (second_map != null), "(first_map != null) && (second_map != null)");
-		if ((first_map != null) && (second_map != null))
-		{
-			var crazy2 = first_map.get(Numberz.TWO);
-			var crazy3 = first_map.get(Numberz.THREE);
-			var looney = second_map.get(Numberz.SIX);
-			rslt.Expect( (crazy2 != null) && (crazy3 != null) && (looney != null), 
-						"(crazy2 != null) && (crazy3 != null) && (looney != null)");
+        var first_map = whoa.get(Int64.make(0,1));
+        var second_map = whoa.get(Int64.make(0,2));
+        rslt.Expect( (first_map != null) && (second_map != null), "(first_map != null) && (second_map != null)");
+        if ((first_map != null) && (second_map != null))
+        {
+            var crazy2 = first_map.get(Numberz.TWO);
+            var crazy3 = first_map.get(Numberz.THREE);
+            var looney = second_map.get(Numberz.SIX);
+            rslt.Expect( (crazy2 != null) && (crazy3 != null) && (looney != null),
+                        "(crazy2 != null) && (crazy3 != null) && (looney != null)");
 
-			rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, 
-						"crazy2.UserMap.get(Numberz.EIGHT) == 8");
-			rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, 
-						"crazy3.UserMap.get(Numberz.EIGHT) == 8");
-			rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, 
-						"crazy2.UserMap.get(Numberz.FIVE) == 5");
-			rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, 
-						"crazy3.UserMap.get(Numberz.FIVE) == 5");
+            rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0,
+                        "crazy2.UserMap.get(Numberz.EIGHT) == 8");
+            rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0,
+                        "crazy3.UserMap.get(Numberz.EIGHT) == 8");
+            rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0,
+                        "crazy2.UserMap.get(Numberz.FIVE) == 5");
+            rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0,
+                        "crazy3.UserMap.get(Numberz.FIVE) == 5");
 
-			var crz2iter = crazy2.xtructs.iterator();
-			var crz3iter = crazy3.xtructs.iterator();
-			rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
-			var goodbye2 = crz2iter.next();
-			var goodbye3 = crz3iter.next();
-			rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
-			var hello2 = crz2iter.next();
-			var hello3 = crz3iter.next();
-			rslt.Expect( ! (crz2iter.hasNext() || crz3iter.hasNext()), "! (crz2iter.hasNext() || crz3iter.hasNext())");
+            var crz2iter = crazy2.xtructs.iterator();
+            var crz3iter = crazy3.xtructs.iterator();
+            rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
+            var goodbye2 = crz2iter.next();
+            var goodbye3 = crz3iter.next();
+            rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
+            var hello2 = crz2iter.next();
+            var hello3 = crz3iter.next();
+            rslt.Expect( ! (crz2iter.hasNext() || crz3iter.hasNext()), "! (crz2iter.hasNext() || crz3iter.hasNext())");
 
-			rslt.Expect( hello2.string_thing == "Hello2", 'hello2.String_thing == "Hello2"');
-			rslt.Expect( hello2.byte_thing == 2, 'hello2.Byte_thing == 2');
-			rslt.Expect( hello2.i32_thing == 2, 'hello2.I32_thing == 2');
-			rslt.Expect( Int64.compare( hello2.i64_thing, Int64.make(0,2)) == 0, 'hello2.I64_thing == 2');
-			rslt.Expect( hello3.string_thing == "Hello2", 'hello3.String_thing == "Hello2"');
-			rslt.Expect( hello3.byte_thing == 2, 'hello3.Byte_thing == 2');
-			rslt.Expect( hello3.i32_thing == 2, 'hello3.I32_thing == 2');
-			rslt.Expect( Int64.compare( hello3.i64_thing, Int64.make(0,2)) == 0, 'hello3.I64_thing == 2');
+            rslt.Expect( hello2.string_thing == "Hello2", 'hello2.String_thing == "Hello2"');
+            rslt.Expect( hello2.byte_thing == 2, 'hello2.Byte_thing == 2');
+            rslt.Expect( hello2.i32_thing == 2, 'hello2.I32_thing == 2');
+            rslt.Expect( Int64.compare( hello2.i64_thing, Int64.make(0,2)) == 0, 'hello2.I64_thing == 2');
+            rslt.Expect( hello3.string_thing == "Hello2", 'hello3.String_thing == "Hello2"');
+            rslt.Expect( hello3.byte_thing == 2, 'hello3.Byte_thing == 2');
+            rslt.Expect( hello3.i32_thing == 2, 'hello3.I32_thing == 2');
+            rslt.Expect( Int64.compare( hello3.i64_thing, Int64.make(0,2)) == 0, 'hello3.I64_thing == 2');
 
-			rslt.Expect( goodbye2.string_thing == "Goodbye4", 'goodbye2.String_thing == "Goodbye4"');
-			rslt.Expect( goodbye2.byte_thing == 4, 'goodbye2.Byte_thing == 4');
-			rslt.Expect( goodbye2.i32_thing == 4, 'goodbye2.I32_thing == 4');
-			rslt.Expect( Int64.compare( goodbye2.i64_thing, Int64.make(0,4)) == 0, 'goodbye2.I64_thing == 4');
-			rslt.Expect( goodbye3.string_thing == "Goodbye4", 'goodbye3.String_thing == "Goodbye4"');
-			rslt.Expect( goodbye3.byte_thing == 4, 'goodbye3.Byte_thing == 4');
-			rslt.Expect( goodbye3.i32_thing == 4, 'goodbye3.I32_thing == 4');
-			rslt.Expect( Int64.compare( goodbye3.i64_thing, Int64.make(0,4)) == 0, 'goodbye3.I64_thing == 4');
-		}
+            rslt.Expect( goodbye2.string_thing == "Goodbye4", 'goodbye2.String_thing == "Goodbye4"');
+            rslt.Expect( goodbye2.byte_thing == 4, 'goodbye2.Byte_thing == 4');
+            rslt.Expect( goodbye2.i32_thing == 4, 'goodbye2.I32_thing == 4');
+            rslt.Expect( Int64.compare( goodbye2.i64_thing, Int64.make(0,4)) == 0, 'goodbye2.I64_thing == 4');
+            rslt.Expect( goodbye3.string_thing == "Goodbye4", 'goodbye3.String_thing == "Goodbye4"');
+            rslt.Expect( goodbye3.byte_thing == 4, 'goodbye3.Byte_thing == 4');
+            rslt.Expect( goodbye3.i32_thing == 4, 'goodbye3.I32_thing == 4');
+            rslt.Expect( Int64.compare( goodbye3.i64_thing, Int64.make(0,4)) == 0, 'goodbye3.I64_thing == 4');
+        }
 
-		var arg0 = 1;
-		var arg1 = 2;
-		var arg2 = Int64.make( 0x7FFFFFFF,0xFFFFFFFF);
-		var multiDict = new IntMap< String>();
-		multiDict.set(1, "one");
-		var arg4 = Numberz.FIVE;
-		var arg5 = Int64.make(0,5000000);
-		trace("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
-		var multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
-		trace(" = Xtruct(byte_thing:" + multiResponse.byte_thing + ",string_thing:" + multiResponse.string_thing
-					+ ",i32_thing:" + multiResponse.i32_thing 
-			        + ",i64_thing:" + Int64.toStr(multiResponse.i64_thing) + ")");
+        var arg0 = 1;
+        var arg1 = 2;
+        var arg2 = Int64.make( 0x7FFFFFFF,0xFFFFFFFF);
+        var multiDict = new IntMap< String>();
+        multiDict.set(1, "one");
+        var arg4 = Numberz.FIVE;
+        var arg5 = Int64.make(0,5000000);
+        trace("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
+        var multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
+        trace(" = Xtruct(byte_thing:" + multiResponse.byte_thing + ",string_thing:" + multiResponse.string_thing
+                    + ",i32_thing:" + multiResponse.i32_thing
+                    + ",i64_thing:" + Int64.toStr(multiResponse.i64_thing) + ")");
 
-		rslt.Expect( multiResponse.string_thing == "Hello2", 'multiResponse.String_thing == "Hello2"');
-		rslt.Expect( multiResponse.byte_thing == arg0, 'multiResponse.Byte_thing == arg0');
-		rslt.Expect( multiResponse.i32_thing == arg1, 'multiResponse.I32_thing == arg1');
-		rslt.Expect( Int64.compare( multiResponse.i64_thing, arg2) == 0, 'multiResponse.I64_thing == arg2');
+        rslt.Expect( multiResponse.string_thing == "Hello2", 'multiResponse.String_thing == "Hello2"');
+        rslt.Expect( multiResponse.byte_thing == arg0, 'multiResponse.Byte_thing == arg0');
+        rslt.Expect( multiResponse.i32_thing == arg1, 'multiResponse.I32_thing == arg1');
+        rslt.Expect( Int64.compare( multiResponse.i64_thing, arg2) == 0, 'multiResponse.I64_thing == arg2');
 
 
-		rslt.StartTestGroup( 0);
+        rslt.StartTestGroup( 0);
 
-		trace("Test Oneway(1)");
-		client.testOneway(1);
+        trace("Test Oneway(1)");
+        client.testOneway(1);
 
-		if( ! args.skipSpeedTest) {
-			trace("Test Calltime()");
-			var difft = Timer.stamp();
-			for ( k in 0 ... 1000) {
-				client.testVoid();
-			}
-			difft = Timer.stamp() - difft;
-			trace('$difft ms per testVoid() call');
-		}
-	}
+        if( ! args.skipSpeedTest) {
+            trace("Test Calltime()");
+            var difft = Timer.stamp();
+            for ( k in 0 ... 1000) {
+                client.testVoid();
+            }
+            difft = Timer.stamp() - difft;
+            trace('$difft ms per testVoid() call');
+        }
+    }
 }
diff --git a/test/haxe/src/TestServer.hx b/test/haxe/src/TestServer.hx
index 92fab01..e9c838f 100644
--- a/test/haxe/src/TestServer.hx
+++ b/test/haxe/src/TestServer.hx
@@ -30,87 +30,87 @@
 
 class TestServer
 {
-	public static function Execute(args : Arguments) :  Void
-	{
-		try
-		{
-			// Transport
-			var transport : TServerTransport = null;
-			switch( args.transport) {
-			case socket:
-				trace("- socket port "+args.port);
-				transport = new TServerSocket( args.port);
-			case http:
-				trace("- http");
-				throw "HTTP server not implemented yet";
-		 		//transport = new THttpServer( targetHost);
-			default:
-				throw "Unhandled transport";
-			}
+    public static function Execute(args : Arguments) :  Void
+    {
+        try
+        {
+            // Transport
+            var transport : TServerTransport = null;
+            switch( args.transport) {
+            case socket:
+                trace("- socket port "+args.port);
+                transport = new TServerSocket( args.port);
+            case http:
+                trace("- http");
+                throw "HTTP server not implemented yet";
+                 //transport = new THttpServer( targetHost);
+            default:
+                throw "Unhandled transport";
+            }
 
-			// optional: layered transport
-			var transfactory : TTransportFactory = null;
-			if ( args.framed) {
-				trace("- framed transport");
-				transfactory = new TFramedTransportFactory();
-			} 
-			if ( args.buffered) {
-				trace("- buffered transport");
-				throw "TBufferedTransport not implemented yet";
-				//transfactory = new TBufferedTransportFactory();
-			}
+            // optional: layered transport
+            var transfactory : TTransportFactory = null;
+            if ( args.framed) {
+                trace("- framed transport");
+                transfactory = new TFramedTransportFactory();
+            }
+            if ( args.buffered) {
+                trace("- buffered transport");
+                throw "TBufferedTransport not implemented yet";
+                //transfactory = new TBufferedTransportFactory();
+            }
 
-			// protocol
-			var protfactory : TProtocolFactory = null;
-			switch( args.protocol)
-			{
-			case binary:
-				trace("- binary protocol");
-				protfactory = new TBinaryProtocolFactory();
-			case json:
-				trace("- json protocol");
-				protfactory = new TJSONProtocolFactory();
-			default:
-				throw "Unhandled protocol";
-			}
+            // protocol
+            var protfactory : TProtocolFactory = null;
+            switch( args.protocol)
+            {
+            case binary:
+                trace("- binary protocol");
+                protfactory = new TBinaryProtocolFactory();
+            case json:
+                trace("- json protocol");
+                protfactory = new TJSONProtocolFactory();
+            default:
+                throw "Unhandled protocol";
+            }
 
-		
-			// Processor
-			var handler = new TestServerHandler();
-			var processor = new ThriftTestProcessor(handler);
 
-			// Simple Server
-			var server : TServer = null; 
-			switch( args.servertype)
-			{
-			case simple:
-				server = new TSimpleServer( processor, transport, transfactory, protfactory);
-			default:
-				throw "Unhandled server type";
-			}
-				
+            // Processor
+            var handler = new TestServerHandler();
+            var processor = new ThriftTestProcessor(handler);
 
-			/*
-			// Server event handler
-			if( args.serverEvents) {
-				var events = new TestServerEventHandler();
-				server.setEventHandler(serverEvents);
-				handler.server = serverEngine;
-			}
-			*/
+            // Simple Server
+            var server : TServer = null;
+            switch( args.servertype)
+            {
+            case simple:
+                server = new TSimpleServer( processor, transport, transfactory, protfactory);
+            default:
+                throw "Unhandled server type";
+            }
 
-			// Run it
-			server.Serve();
-			trace("done.");
 
-		}
-		catch (x : TException)
-		{
-			trace('$x');
-		}
-		catch (x : Dynamic)
-		{
-			trace('$x');
-		}
-	}
+            /*
+            // Server event handler
+            if( args.serverEvents) {
+                var events = new TestServerEventHandler();
+                server.setEventHandler(serverEvents);
+                handler.server = serverEngine;
+            }
+            */
+
+            // Run it
+            server.Serve();
+            trace("done.");
+
+        }
+        catch (x : TException)
+        {
+            trace('$x');
+        }
+        catch (x : Dynamic)
+        {
+            trace('$x');
+        }
+    }
 }
diff --git a/test/haxe/src/TestServerEventHandler.hx b/test/haxe/src/TestServerEventHandler.hx
index b52943a..d17567c 100644
--- a/test/haxe/src/TestServerEventHandler.hx
+++ b/test/haxe/src/TestServerEventHandler.hx
@@ -30,24 +30,24 @@
 
 class TestServerEventHandler : TServerEventHandler
 {
-	public int callCount = 0;
-	public void preServe()
-	{
-		callCount++;
-	}
-	public Object createContext(Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
-	{
-		callCount++;
-		return null;
-	}
-	public void deleteContext(Object serverContext, Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
-	{
-		callCount++;
-	}
-	public void processContext(Object serverContext, Thrift.Transport.TTransport transport)
-	{
-		callCount++;
-	}
+    public int callCount = 0;
+    public void preServe()
+    {
+        callCount++;
+    }
+    public Object createContext(Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
+    {
+        callCount++;
+        return null;
+    }
+    public void deleteContext(Object serverContext, Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
+    {
+        callCount++;
+    }
+    public void processContext(Object serverContext, Thrift.Transport.TTransport transport)
+    {
+        callCount++;
+    }
 }
 
-	
\ No newline at end of file
+    
\ No newline at end of file
diff --git a/test/haxe/src/TestServerHandler.hx b/test/haxe/src/TestServerHandler.hx
index e988adb..f067bde 100644
--- a/test/haxe/src/TestServerHandler.hx
+++ b/test/haxe/src/TestServerHandler.hx
@@ -43,428 +43,428 @@
     public function new() {
     }
 
-	/**
-	* Prints "testVoid()" and returns nothing.
-	*/
+    /**
+    * Prints "testVoid()" and returns nothing.
+    */
     public function testVoid():Void
     {
-    	trace("testVoid()");
+        trace("testVoid()");
     }
 
-	/**
-	* Prints 'testString("%s")' with thing as '%s'
-	* @param string thing - the string to print
-	* @return string - returns the string 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testString("%s")' with thing as '%s'
+    * @param string thing - the string to print
+    * @return string - returns the string 'thing'
+    *
+    * @param thing
+    */
     public function testString(thing:String):String
     {
-    	trace("teststring(\"" + thing + "\")");
-    	return thing;
+        trace("teststring(\"" + thing + "\")");
+        return thing;
     }
 
-	/**
-	* Prints 'testByte("%d")' with thing as '%d'
-	* @param byte thing - the byte to print
-	* @return byte - returns the byte 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testByte("%d")' with thing as '%d'
+    * @param byte thing - the byte to print
+    * @return byte - returns the byte 'thing'
+    *
+    * @param thing
+    */
     public function testByte(thing:haxe.Int32):haxe.Int32
     {
-    	trace("testByte(" + thing + ")");
-    	return thing;
+        trace("testByte(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testI32("%d")' with thing as '%d'
-	* @param i32 thing - the i32 to print
-	* @return i32 - returns the i32 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testI32("%d")' with thing as '%d'
+    * @param i32 thing - the i32 to print
+    * @return i32 - returns the i32 'thing'
+    *
+    * @param thing
+    */
     public function testI32(thing:haxe.Int32):haxe.Int32
     {
-    	trace("testI32(" + thing + ")");
-    	return thing;
+        trace("testI32(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testI64("%d")' with thing as '%d'
-	* @param i64 thing - the i64 to print
-	* @return i64 - returns the i64 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testI64("%d")' with thing as '%d'
+    * @param i64 thing - the i64 to print
+    * @return i64 - returns the i64 'thing'
+    *
+    * @param thing
+    */
     public function testI64(thing:haxe.Int64):haxe.Int64
     {
-    	trace("testI64(" + thing + ")");
-    	return thing;
+        trace("testI64(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testDouble("%f")' with thing as '%f'
-	* @param double thing - the double to print
-	* @return double - returns the double 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testDouble("%f")' with thing as '%f'
+    * @param double thing - the double to print
+    * @return double - returns the double 'thing'
+    *
+    * @param thing
+    */
     public function testDouble(thing:Float):Float
     {
-    	trace("testDouble(" + thing + ")");
-    	return thing;
+        trace("testDouble(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testStruct("{%s}")' where thing has been formatted 
+    /**
+    * Prints 'testStruct("{%s}")' where thing has been formatted
     *  into a string of comma seperated values
-	* @param Xtruct thing - the Xtruct to print
-	* @return Xtruct - returns the Xtruct 'thing'
-	* 
-	* @param thing
-	*/
+    * @param Xtruct thing - the Xtruct to print
+    * @return Xtruct - returns the Xtruct 'thing'
+    *
+    * @param thing
+    */
     public function testStruct(thing:Xtruct):Xtruct
     {
-    	trace("testStruct({" + 
-                          "\"" + thing.string_thing + "\", " + 
-                          thing.byte_thing + ", " + 
-                          thing.i32_thing + ", " + 
+        trace("testStruct({" +
+                          "\"" + thing.string_thing + "\", " +
+                          thing.byte_thing + ", " +
+                          thing.i32_thing + ", " +
                           Int64.toStr(thing.i64_thing) + "})");
-    	return thing;
+        return thing;
     }
 
-	/**
-	* Prints 'testNest("{%s}")' where thing has been formatted 
+    /**
+    * Prints 'testNest("{%s}")' where thing has been formatted
     *  into a string of the nested struct
-	* @param Xtruct2 thing - the Xtruct2 to print
-	* @return Xtruct2 - returns the Xtruct2 'thing'
-	* 
-	* @param thing
-	*/
+    * @param Xtruct2 thing - the Xtruct2 to print
+    * @return Xtruct2 - returns the Xtruct2 'thing'
+    *
+    * @param thing
+    */
     public function testNest(nest:Xtruct2):Xtruct2
     {
-    	var thing:Xtruct = nest.struct_thing;
-    	trace("testNest({" + 
-                          nest.byte_thing + ", {" + 
-                          "\"" + thing.string_thing + "\", " + 
-                          thing.byte_thing + ", " + 
-                          thing.i32_thing + ", " + 
-                          Int64.toStr(thing.i64_thing) + "}, " + 
+        var thing:Xtruct = nest.struct_thing;
+        trace("testNest({" +
+                          nest.byte_thing + ", {" +
+                          "\"" + thing.string_thing + "\", " +
+                          thing.byte_thing + ", " +
+                          thing.i32_thing + ", " +
+                          Int64.toStr(thing.i64_thing) + "}, " +
                           nest.i32_thing + "})");
-    	return nest;
+        return nest;
     }
 
-	/**
-	* Prints 'testMap("{%s")' where thing has been formatted
+    /**
+    * Prints 'testMap("{%s")' where thing has been formatted
     *  into a string of  'key => value' pairs
-	*  seperated by commas and new lines
-	* @param map<i32,i32> thing - the map<i32,i32> to print
-	* @return map<i32,i32> - returns the map<i32,i32> 'thing'
-	* 
-	* @param thing
-	*/
+    *  seperated by commas and new lines
+    * @param map<i32,i32> thing - the map<i32,i32> to print
+    * @return map<i32,i32> - returns the map<i32,i32> 'thing'
+    *
+    * @param thing
+    */
     public function testMap(thing:IntMap<haxe.Int32>):IntMap<haxe.Int32>
     {
-    	trace("testMap({");
-    	var first:Bool = true;
-    	for (key in thing.keys()) {
-    		if (first) {
-    			first = false;
-    		} else {
-    			trace(", ");
-    		};
-    		trace(key + " => " + thing.get(key));
-    	};
-    	trace("})");
-    	return thing;
+        trace("testMap({");
+        var first:Bool = true;
+        for (key in thing.keys()) {
+            if (first) {
+                first = false;
+            } else {
+                trace(", ");
+            };
+            trace(key + " => " + thing.get(key));
+        };
+        trace("})");
+        return thing;
     }
 
-	/**
-	* Prints 'testStringMap("{%s}")' where thing has been formatted 
+    /**
+    * Prints 'testStringMap("{%s}")' where thing has been formatted
     *  into a string of  'key => value' pairs
-	*  seperated by commas and new lines
-	* @param map<string,string> thing - the map<string,string> to print
-	* @return map<string,string> - returns the map<string,string> 'thing'
-	* 
-	* @param thing
-	*/
+    *  seperated by commas and new lines
+    * @param map<string,string> thing - the map<string,string> to print
+    * @return map<string,string> - returns the map<string,string> 'thing'
+    *
+    * @param thing
+    */
     public function testStringMap(thing:StringMap<String>):StringMap<String>
     {
-    	trace("testStringMap({");
-    	var first:Bool = true;
-    	for (key in thing.keys()) {
-    		if (first) {
-    			first = false;
-    		} else {
-    			trace(", ");
-    		};
-    		trace(key + " => " + thing.get(key));
-    	};
-    	trace("})");
-    	return thing;
+        trace("testStringMap({");
+        var first:Bool = true;
+        for (key in thing.keys()) {
+            if (first) {
+                first = false;
+            } else {
+                trace(", ");
+            };
+            trace(key + " => " + thing.get(key));
+        };
+        trace("})");
+        return thing;
     }
 
-	/**
-	* Prints 'testSet("{%s}")' where thing has been formatted 
+    /**
+    * Prints 'testSet("{%s}")' where thing has been formatted
     *  into a string of  values
-	*  seperated by commas and new lines
-	* @param set<i32> thing - the set<i32> to print
-	* @return set<i32> - returns the set<i32> 'thing'
-	* 
-	* @param thing
-	*/
+    *  seperated by commas and new lines
+    * @param set<i32> thing - the set<i32> to print
+    * @return set<i32> - returns the set<i32> 'thing'
+    *
+    * @param thing
+    */
     public function testSet(thing:IntSet):IntSet
     {
-    	trace("testSet({");
-    	var first:Bool = true;
-    	for (elem in thing) {
-    		if (first) {
-    			first = false;
-    		} else {
-    			trace(", ");
-    		};
-    		trace(elem);
-    	};
-    	trace("})");
-    	return thing;
+        trace("testSet({");
+        var first:Bool = true;
+        for (elem in thing) {
+            if (first) {
+                first = false;
+            } else {
+                trace(", ");
+            };
+            trace(elem);
+        };
+        trace("})");
+        return thing;
     }
 
-	/**
-	* Prints 'testList("{%s}")' where thing has been formatted 
+    /**
+    * Prints 'testList("{%s}")' where thing has been formatted
     *  into a string of  values
-	*  seperated by commas and new lines
-	* @param list<i32> thing - the list<i32> to print
-	* @return list<i32> - returns the list<i32> 'thing'
-	* 
-	* @param thing
-	*/
+    *  seperated by commas and new lines
+    * @param list<i32> thing - the list<i32> to print
+    * @return list<i32> - returns the list<i32> 'thing'
+    *
+    * @param thing
+    */
     public function testList(thing:List<haxe.Int32>):List<haxe.Int32>
     {
-    	trace("testList({");
-    	var first:Bool = true;
-    	for (elem in thing) {
-    		if (first) {
-    			first = false;
-    		} else {
-    			trace(", ");
-    		};
-    		trace(elem);
-    	};
-    	trace("})");
-    	return thing;
+        trace("testList({");
+        var first:Bool = true;
+        for (elem in thing) {
+            if (first) {
+                first = false;
+            } else {
+                trace(", ");
+            };
+            trace(elem);
+        };
+        trace("})");
+        return thing;
     }
 
-	/**
-	* Prints 'testEnum("%d")' where thing has been formatted into it's numeric value
-	* @param Numberz thing - the Numberz to print
-	* @return Numberz - returns the Numberz 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testEnum("%d")' where thing has been formatted into it's numeric value
+    * @param Numberz thing - the Numberz to print
+    * @return Numberz - returns the Numberz 'thing'
+    *
+    * @param thing
+    */
     public function testEnum(thing:Int):Int
     {
-    	trace("testEnum(" + thing + ")");
-    	return thing;
+        trace("testEnum(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testTypedef("%d")' with thing as '%d'
-	* @param UserId thing - the UserId to print
-	* @return UserId - returns the UserId 'thing'
-	* 
-	* @param thing
-	*/
+    /**
+    * Prints 'testTypedef("%d")' with thing as '%d'
+    * @param UserId thing - the UserId to print
+    * @return UserId - returns the UserId 'thing'
+    *
+    * @param thing
+    */
     public function testTypedef(thing:haxe.Int64):haxe.Int64
     {
-    	trace("testTypedef(" + thing + ")");
-    	return thing;
+        trace("testTypedef(" + thing + ")");
+        return thing;
     }
 
-	/**
-	* Prints 'testMapMap("%d")' with hello as '%d'
-	* @param i32 hello - the i32 to print
-	* @return map<i32,map<i32,i32>> - returns a dictionary with these values:
-	*   {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 
-	*     4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, }
-	* 
-	* @param hello
-	*/
+    /**
+    * Prints 'testMapMap("%d")' with hello as '%d'
+    * @param i32 hello - the i32 to print
+    * @return map<i32,map<i32,i32>> - returns a dictionary with these values:
+    *   {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, },
+    *     4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, }
+    *
+    * @param hello
+    */
     public function testMapMap(hello:haxe.Int32):IntMap<IntMap<haxe.Int32>>
     {
-    	trace("testMapMap(" + hello + ")");
-    	var mapmap = new IntMap<IntMap<Int>>();
-    	var pos = new IntMap<Int>();
-    	var neg = new IntMap<Int>();
-    	for (i in 1 ... 5) {
-    		pos.set(i, i);
-    		neg.set(-i, -i);
-    	};
-    	mapmap.set(4, pos);
-    	mapmap.set(-4, neg);
-    	return mapmap;
+        trace("testMapMap(" + hello + ")");
+        var mapmap = new IntMap<IntMap<Int>>();
+        var pos = new IntMap<Int>();
+        var neg = new IntMap<Int>();
+        for (i in 1 ... 5) {
+            pos.set(i, i);
+            neg.set(-i, -i);
+        };
+        mapmap.set(4, pos);
+        mapmap.set(-4, neg);
+        return mapmap;
     }
 
-	/**
-	* So you think you've got this all worked, out eh?
-	* 
-	* Creates a the returned map with these values and prints it out:
-	*   { 1 => { 2 => argument,
-	*            3 => argument,
-	*          },
-	*     2 => { 6 => <empty Insanity struct>, },
-	*   }
-	* @return map<UserId, map<Numberz,Insanity>> - a map with the above values
-	* 
-	* @param argument
-	*/
+    /**
+    * So you think you've got this all worked, out eh?
+    *
+    * Creates a the returned map with these values and prints it out:
+    *   { 1 => { 2 => argument,
+    *            3 => argument,
+    *          },
+    *     2 => { 6 => <empty Insanity struct>, },
+    *   }
+    * @return map<UserId, map<Numberz,Insanity>> - a map with the above values
+    *
+    * @param argument
+    */
     public function testInsanity(argument : Insanity) : Int64Map< IntMap< Insanity>>
     {
-    	trace("testInsanity()");
+        trace("testInsanity()");
 
-    	var hello = new Xtruct();
-    	hello.string_thing = "Hello2";
-    	hello.byte_thing = 2;
-    	hello.i32_thing = 2;
-    	hello.i64_thing = Int64.make(0, 2);
+        var hello = new Xtruct();
+        hello.string_thing = "Hello2";
+        hello.byte_thing = 2;
+        hello.i32_thing = 2;
+        hello.i64_thing = Int64.make(0, 2);
 
-    	var goodbye = new Xtruct();
-    	goodbye.string_thing = "Goodbye4";
-    	goodbye.byte_thing = 4;
-    	goodbye.i32_thing = 4;
-    	goodbye.i64_thing = Int64.make(0, 4);
+        var goodbye = new Xtruct();
+        goodbye.string_thing = "Goodbye4";
+        goodbye.byte_thing = 4;
+        goodbye.i32_thing = 4;
+        goodbye.i64_thing = Int64.make(0, 4);
 
-    	var crazy = new Insanity();
-		crazy.userMap = new IntMap< haxe.Int64>();
-    	crazy.userMap.set(Numberz.EIGHT, Int64.make(0,8));
-    	crazy.xtructs = new List<Xtruct>();
-    	crazy.xtructs.add(goodbye);
+        var crazy = new Insanity();
+        crazy.userMap = new IntMap< haxe.Int64>();
+        crazy.userMap.set(Numberz.EIGHT, Int64.make(0,8));
+        crazy.xtructs = new List<Xtruct>();
+        crazy.xtructs.add(goodbye);
 
-    	var looney = new Insanity();
-    	crazy.userMap.set(Numberz.FIVE, Int64.make(0,5));
-    	crazy.xtructs.add(hello);
+        var looney = new Insanity();
+        crazy.userMap.set(Numberz.FIVE, Int64.make(0,5));
+        crazy.xtructs.add(hello);
 
-    	var first_map = new IntMap< Insanity>();
-    	first_map.set(Numberz.TWO, crazy);
-    	first_map.set(Numberz.THREE, crazy);
+        var first_map = new IntMap< Insanity>();
+        first_map.set(Numberz.TWO, crazy);
+        first_map.set(Numberz.THREE, crazy);
 
-    	var second_map = new IntMap< Insanity>();
-    	second_map.set(Numberz.SIX, looney);
+        var second_map = new IntMap< Insanity>();
+        second_map.set(Numberz.SIX, looney);
 
-		var insane = new Int64Map< IntMap< Insanity>>();
-    	insane.set( Int64.make(0,1), first_map);
-    	insane.set( Int64.make(0,2), second_map);
+        var insane = new Int64Map< IntMap< Insanity>>();
+        insane.set( Int64.make(0,1), first_map);
+        insane.set( Int64.make(0,2), second_map);
 
-    	return insane;
+        return insane;
     }
 
-	/**
-	* Prints 'testMulti()'
-	* @param byte arg0 -
-	* @param i32 arg1 -
-	* @param i64 arg2 -
-	* @param map<i16, string> arg3 -
-	* @param Numberz arg4 -
-	* @param UserId arg5 -
-	* @return Xtruct - returns an Xtruct 
+    /**
+    * Prints 'testMulti()'
+    * @param byte arg0 -
+    * @param i32 arg1 -
+    * @param i64 arg2 -
+    * @param map<i16, string> arg3 -
+    * @param Numberz arg4 -
+    * @param UserId arg5 -
+    * @return Xtruct - returns an Xtruct
     *    with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1
-	*    and i64_thing = arg2
-	* 
-	* @param arg0
-	* @param arg1
-	* @param arg2
-	* @param arg3
-	* @param arg4
-	* @param arg5
-	*/
-    public function testMulti(arg0:haxe.Int32, arg1:haxe.Int32, arg2:haxe.Int64, 
+    *    and i64_thing = arg2
+    *
+    * @param arg0
+    * @param arg1
+    * @param arg2
+    * @param arg3
+    * @param arg4
+    * @param arg5
+    */
+    public function testMulti(arg0:haxe.Int32, arg1:haxe.Int32, arg2:haxe.Int64,
         arg3:IntMap<String>, arg4:Int, arg5:haxe.Int64):Xtruct
     {
-    	trace("testMulti()");
-    	var hello = new Xtruct();
-    	hello.string_thing = "Hello2";
-    	hello.byte_thing = arg0;
-    	hello.i32_thing = arg1;
-    	hello.i64_thing = arg2;
-    	return hello;
+        trace("testMulti()");
+        var hello = new Xtruct();
+        hello.string_thing = "Hello2";
+        hello.byte_thing = arg0;
+        hello.i32_thing = arg1;
+        hello.i64_thing = arg2;
+        return hello;
     }
 
-	/**
-	* Print 'testException(%s)' with arg as '%s'
-	* @param string arg - a string indication what type of exception to throw
-	* if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
-	* elsen if arg == "TException" throw TException
-	* else do not throw anything
-	* 
-	* @param arg
-	*/
+    /**
+    * Print 'testException(%s)' with arg as '%s'
+    * @param string arg - a string indication what type of exception to throw
+    * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
+    * elsen if arg == "TException" throw TException
+    * else do not throw anything
+    *
+    * @param arg
+    */
     public function testException(arg:String):Void
     {
-    	trace("testException(" + arg + ")");
-    	if (arg == "Xception") {
-    		var x = new Xception();
-    		x.errorCode = 1001;
-    		x.message = arg;
-    		throw x;
-    	};
-    	if (arg == "TException") {
-    		throw new TException();
-    	};		
-    	return;
+        trace("testException(" + arg + ")");
+        if (arg == "Xception") {
+            var x = new Xception();
+            x.errorCode = 1001;
+            x.message = arg;
+            throw x;
+        };
+        if (arg == "TException") {
+            throw new TException();
+        };
+        return;
     }
 
-	/**
-	* Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s'
-	* @param string arg - a string indication what type of exception to throw
-	* if arg0 == "Xception" 
-	* throw Xception with errorCode = 1001 and message = "This is an Xception"
-	* else if arg0 == "Xception2" 
-	* throw Xception2 with errorCode = 2002 and message = "This is an Xception2"
-	* else do not throw anything
-	* @return Xtruct - an Xtruct with string_thing = arg1
-	* 
-	* @param arg0
-	* @param arg1
-	*/
+    /**
+    * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s'
+    * @param string arg - a string indication what type of exception to throw
+    * if arg0 == "Xception"
+    * throw Xception with errorCode = 1001 and message = "This is an Xception"
+    * else if arg0 == "Xception2"
+    * throw Xception2 with errorCode = 2002 and message = "This is an Xception2"
+    * else do not throw anything
+    * @return Xtruct - an Xtruct with string_thing = arg1
+    *
+    * @param arg0
+    * @param arg1
+    */
     public function testMultiException(arg0:String, arg1:String):Xtruct
     {
-    	trace("testMultiException(" + arg0 + ", " + arg1 + ")");
-    	if (arg0 == "Xception") {
-    		var x = new Xception();
-    		x.errorCode = 1001;
-    		x.message = "This is an Xception";
-    		throw x;
-    	} else if (arg0 == "Xception2") {
-    		var x = new Xception2();
-    		x.errorCode = 2002;
-    		x.struct_thing = new Xtruct();
-    		x.struct_thing.string_thing = "This is an Xception2";
-    		throw x;
-    	};
-    	var result = new Xtruct();
-    	result.string_thing = arg1;
-    	return result;
+        trace("testMultiException(" + arg0 + ", " + arg1 + ")");
+        if (arg0 == "Xception") {
+            var x = new Xception();
+            x.errorCode = 1001;
+            x.message = "This is an Xception";
+            throw x;
+        } else if (arg0 == "Xception2") {
+            var x = new Xception2();
+            x.errorCode = 2002;
+            x.struct_thing = new Xtruct();
+            x.struct_thing.string_thing = "This is an Xception2";
+            throw x;
+        };
+        var result = new Xtruct();
+        result.string_thing = arg1;
+        return result;
     }
 
-	/**
-	* Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d'
-	* sleep 'secondsToSleep'
-	* Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d'
-	* @param i32 secondsToSleep - the number of seconds to sleep
-	* 
-	* @param secondsToSleep
-	*/
+    /**
+    * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d'
+    * sleep 'secondsToSleep'
+    * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d'
+    * @param i32 secondsToSleep - the number of seconds to sleep
+    *
+    * @param secondsToSleep
+    */
     public function testOneway(secondsToSleep:haxe.Int32):Void
     {
-    	trace("testOneway(" + secondsToSleep + "), sleeping...");
-    	Sys.sleep(secondsToSleep);
-    	trace("testOneway finished");
+        trace("testOneway(" + secondsToSleep + "), sleeping...");
+        Sys.sleep(secondsToSleep);
+        trace("testOneway finished");
     }
 
     public function testStop():Void
     {
-    	if (server != null) {
-    		server.Stop();
-    	};
+        if (server != null) {
+            server.Stop();
+        };
     }
 }
