Various fixes for py3