generalize xy and xyz queries; do in-app join
make the 'reduce' more readable
Merge branch 'generalize-xy-query'