Changes to make it run smoothly on Python 2 and Python 3