Internal refactoring in QueryBuilder