Small refactoring and documentation