add documentation
Documentation and minor code style changes.
Add lots of docs and format them for docco.