Better implementation of HaxeRemote - doesn't suffer from concurrent writes
to the socket and thus doesn't die randomly when thread events occur.