Fixed SELECT DISTINCT bug.