Improved logging, docstrings, and comments.