Refactoring client stuff