Refactor client stuff