Complete refactoring.

- Add debug mode.
- New service interface.
- Extract pinger.
- Add history.
- Compute status change from history.