Tweaking to work in Python3