CODE: Modifications to do_exit to make better.