Strong refactor of client.
Refactor client into separate files