Refactored importer heavy-lifting to lib.