Added more docstrings. Minor cleanup.