query fixes for new query builder