Move the query builder into the core.