Added documentation for the API
Tidied up some comments and names