Fix bugs in client