Tweaks to make things work on Python 2