messy port to python 2.x