Cleaned up and expanded docstrings and comments