More refactoring in python bindings.