Finish refactoring emergency state to a service.