Fix iteritems() call in python3.
Fix regexs to be compatible with Python2.6.