Added support for python 3's rearranged standard library
Move from .iteritems() to .items() for dict iteration
Changed lambda to support python 3 syntax changes