cleanup, refactor client stuff