Handle duplicates
Bug fixes