Some fixes for Python 3