Added lots of docstrings and renamed some methods.