Port to python 2.x