Added better docstrings and comments