Fixes for python3 support