Replaced iteritems() with items() for python3 compatibility.