Use dict.items instead of iteritems for python 3 compatibility