Various fixes for Python3 compliance.