Moved some code from rake task to importer module