Add some comments and docstrings