Fix #170:  handle namespaces in queries

Review this PR *after* #254 is merged (it is based from that branch).

Fixes #170.
Why not a property?

I suppose this fits under the #188 umbrella?