add docstrings, cleanup