documentation and some refactoring