Fixed multiple bugs in server.