Refactored client to be more modular