Fixes to maintain python 3 support