reorganized unload() code into 'Phases'