QueryGraph refactoring