Fix issue with multiple identical keys, speed up search