Started refactoring of python bindings code.