Minor changes to make this work under python 2.x