qp refactoring