Adding support for DISTINCT (and inserts, untested)