Add register alarm after reboot.
Refactor code.