Minor fixes to make it work on py 3.x