More refactoring to exit status handling.