Fixes for py3. Remaining errors due to issues with pylisting and doctest-ignore