Refactor query storage out to its own class

- Create QueryStore to keep track of in-flight queries.