Debug & enhancement of clean_exit