Fixed server bug; cleaned up client code