Adding a template log2 function and refactoring Watchdog usage.