minor tweeks to make it work with python 3