Major refactoring of importing