Query builder cleanup