Minor client fixes and refactoring
[client] refactoring and code cleanup