Add docstrings and comments.