Improve unload and error management