Fixed docstrings and added comments in the script

Fixed some of the docstrings and added useful comments.