More work on the query builder