Fix some bugs in client.js