Fix some errors when connect to server. Add return status to server.