Fixed bugs in server implementation