Optimisations, error handling and fixes. Tests not passing.
Fix test.
Make it a little bit faster.
Merge pull request #27 from timlinux/optimisation

Optimisations, error handling and fixes. Tests not passing.

2 failed test related to client's data.