Extracted QueryService into portable core.