Added comments and docstrings to make the methods more readable.