docstrings and general cleanup.