Added comments and corrected typos in docstring