Add check for internal duplicates on import

Let me know what you think. If this looks OK, I'll write a few tests.