More fixes for queries regarding DISTINCT.