Refactor query generator code to use a local profiling library