Added option allowDuplicates

Used to allow users to add the same entry more than once.
Modified addToSelection() and _sortAndTrim methods().