Querying comparison with Coherence

This PR generally allows comparison of querying with Coherence - some refactoring was necessary to do that, and minor bugs and flaws found during development were fixed.