Docstrings and refactoring.