Add documentation and minor code-refactoring

It should