Added watchdog for debug purpose. refactored a bit debug helpers