Removes duplicates from selection, renames retreive to Retrieve and fixes several bugs in Retrieve