Query builder fixes; query builder output handling