some documentation + some refactoring.