Added a few comments and docstrings.