Fix possible race condition in the import