fixed the issue in removing duplicate items, fixes #356
some tweaks, refs #356