Various changes to make code compatible with both Python 2.7 and Python 3.