Added docstrings and comments.