Fixes query bugs.