Query builder improvements