Massive re-write to use WDT and sleep libraries.