python 3: fix more circular dependencies / use more explicit imports.