add more docstrings; some cleanup