WIP: client refactoring