Changes for migrating code to Python 3