Still has bug in tests, but imports work even with duplicates and cycles