Added docstrings.
Added function docstrings and improved whitespace usage.