Minor pylint/style fixes.

Updates changed files from a combined 4.39/10.0 pylint score
to 6.56/10.0.

* Fixes usage of Python builtins as variable names.
* Removes unused variables.
* Removes unused imports.
* Adds some docstrings.
* Fixes old-style exception handling.
* Adds missing `with` statement to json file handling.
* Replaces old-style class declaration.