Switch to python 3 and make more pythonic.