Small changes to make it work on Python3