fix bugs in CaveServer
clean up old code