Documentation and refactoring