Fixed some bugs in server