updated docstrings and made the source more readable.