More docstrings and cleanup