Comments and docstrings added