docstrings and tiny refactoring