WIP: refactoring client code.