Minor refactoring for better reboot behavior.