Fixed issue in assigning duplicates.
Merge pull request #27 from ahukkanen/duplicates_bugfix

Fixed issue in assigning duplicates.