Added docstrings.

Added a docstring to each function in the script, explaining exactly
what is going on.