Minor tweaks to building queries. namespace fixes.