Moved cleanup code into the import code