Made the code work in Python3.