Fixed bugs with query unions.