Refactored owin main query processor