Refactoring Python integration.