Slowly converting code to Python 3