Added docstrings.  Cleaned up code (broke up long lines, removed unused

variable references, pep8 formatted most of the code (one set of long lines
remains), and changed some variable and method names to conform to pylint
standards).

Fixes: 6530