Added a bit more smarts to detect which duplicate is the original.