Remove some bugs, server can exit after a long idle time