fixed some bugs in the server code