Fixed some race-conditions that was affecting reconnecting and adding debug loging to client side code