Necessary changes for py3port

What I have found and fixed.