fix some bugs in client implementation