some documentation and slight code refactoring