Made the new code compatible with Python 2.7.