Merge in code cleanups from Gordon Sim, fixed some issues found by PyLint