Initial port to python 3.x