common code for Import and Final pass