Merge "First stage of refactoring the code to handle crashes gracefully."