Minor readability / performance / deprecation improvements

- replace string concat with string formatting
- replace deprecated ``has_key`` with ``in``
- use ``get`` method with default instead of checking for inclusion
- replaced ``lambda x: x[1]`` with a single definition of ``itemgetter(1)``
- use ``max`` with ``key`` instead of sort-reverse-first anti-pattern