Changes to make it work with Python 3