Fixed a count distinct bug that non-distinct keys can get counted multiples times.