Add documentation and minor code-refactoring

API, done