more documentation, and some refactoring