start refactoring of partial optimality implementation