Changes to be compatible with Python 3