diff --git a/game/profile-thread/Client.lua b/game/profile-thread/Client.lua
index b99fea916b4a25bffbfc05920056050b16f30775..8b9f60b0d6537e5d73fd76c49e724fa332c6f06d 100644
--- a/game/profile-thread/Client.lua
+++ b/game/profile-thread/Client.lua
@@ -120,6 +120,7 @@ function _M:pread(ncode)
 end
 
 function _M:login()
+print("profile login", self.sock , self.auth , self.user_login , self.user_pass)
 	if self.sock and not self.auth and self.user_login and self.user_pass then
 		self:command("AUTH", self.user_login)
 		self:read("200")
@@ -193,6 +194,7 @@ function _M:run()
 end
 
 function _M:handleOrder(o)
+	print("==== profile order ====", o)
 	o = o:unserialize()
 	if not self.sock and o.o ~= "Login" and o.o ~= "CurrentCharacter" and o.o ~= "CheckModuleHash" then return end -- Dont do stuff without a connection, unless we try to auth
 	if self["order"..o.o] then self["order"..o.o](self, o) end
@@ -212,13 +214,15 @@ function _M:orderNewProfile2(o)
 end
 
 function _M:orderLogin(o)
+	self.user_login = o.l
+	self.user_pass = o.p
+	print("profile strogin login info", o.l, o.p)
+
 	-- Already logged?
 	if self.auth and self.auth.login == o.l then
 		print("[PROFILE] reusing login", self.auth.name)
 		cprofile.pushEvent(string.format("e='Auth' ok=%q", table.serialize(self.auth)))
 	else
-		self.user_login = o.l
-		self.user_pass = o.p
 		self:login()
 	end
 end
@@ -314,7 +318,9 @@ end
 
 function _M:orderChatJoin(o)
 	self:command("JOIN", o.channel)
-	self:read("200")
+	if self:read("200") then
+		self.chat:joined(o.channel)
+	end
 end
 
 function _M:orderChatUserInfo(o)
diff --git a/game/profile-thread/init.lua b/game/profile-thread/init.lua
index 50b44f33415ecdd1f1517e48e38328dd3cb330b5..7c8dc4bfbe93a4cd6b865cea45e98a11d25f2204 100644
--- a/game/profile-thread/init.lua
+++ b/game/profile-thread/init.lua
@@ -25,6 +25,7 @@ local c = Client.new()
 function step_profile()
 	local ok, res = xpcall(function() return c:run() end, function(...) server:logError("[profile-thread-error:stacktrace] %s", debug.traceback(...)) end)
 	if not ok and res then
+		print("[PROFILE THREAD] error", res)
 		return false
 	end
 	return res
diff --git a/src/profile.c b/src/profile.c
index 39c32c70ffc8be7f4f272d32d56ae093c081bbfc..67a44c096e668a2a6fea8a2f73615f66ccd3d8d7 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -67,6 +67,7 @@ int pop_order(lua_State *L)
 
 	if (q)
 	{
+//		printf("[profile event] POP %s\n", q->payload);
 		lua_pushlstring(L, q->payload, q->payload_len);
 		free(q->payload);
 		free(q);
@@ -141,11 +142,6 @@ int thread_profile(void *data)
 	luaL_openlib(L, "cprofile", threadlib, 0); lua_pop(L, 1);
 
 	profile->L = L;
-	profile->iqueue_head = profile->iqueue_tail = profile->oqueue_head = profile->oqueue_tail = NULL;
-	profile->lock_iqueue = SDL_CreateMutex();
-	profile->wait_iqueue = SDL_CreateSemaphore(0);
-	profile->lock_oqueue = SDL_CreateMutex();
-	profile->wait_oqueue = SDL_CreateSemaphore(0);
 
 	// And run the lua engine pre init scripts
 	if (!luaL_loadfile(L, "/loader/pre-init.lua")) docall(L, 0, 0);
@@ -180,6 +176,11 @@ int create_profile_thread(lua_State *L)
 	main_profile = profile;
 
 	profile->running = TRUE;
+	profile->iqueue_head = profile->iqueue_tail = profile->oqueue_head = profile->oqueue_tail = NULL;
+	profile->lock_iqueue = SDL_CreateMutex();
+	profile->wait_iqueue = SDL_CreateSemaphore(0);
+	profile->lock_oqueue = SDL_CreateMutex();
+	profile->wait_oqueue = SDL_CreateSemaphore(0);
 
 	thread = SDL_CreateThread(thread_profile, profile);
 	if (thread == NULL) {