NFC: Cleans up code for long lines, indentation.

This non functional change fixes up some pychecker/pep8 reports:

  * wraps long lines
  * fixes indentation (4 spaces instead of 2)
  * replaces a few try/except KeyError blocks that worked around
    KeyError by using dictionary.get(key, default) for readability.