Issue #188: fix bad back reference and query scope