Further compatibility fixes for python 3