Framework: Refactor complex functions in PLRSearch