Added docstrings, updated comments and other minor changes