several bug fixes for client