Add documentation

* Add a user guide
* Add a sample implementation
* Tidy up some of the code slightly