Various fixes to support compilation / tests on Python3.