Initial port to python 3