Minor query bugs