Added docstrings and comments here and there