Re-wrote the import/export code.