Core: The query string cache should returned clones Query instances.

The query string cache can't return the same instance, since Query is mutable changing the query else where in the execution path changes the instance in the cache too.

Fixes #2542