Add Watchdog class and unit tests. Minor improvements to Thread