Small improvements to query builder