refactored client.
added documentation.