Full support for DISTINCT in aggregations

Not yet ready for commiting