Correctly track the source of imports with the same name

Resolves #6633 and removes an unnecessary import in libcore