Added DISTINCT to a bunch of the queries.