Fixing some bugs in the sever