Add documentation and minor code-refactoring

Well done!