Various small fixes for Python 3