misc improvements to query builder