Small refactoring and docstrings