Bugfixes and added watchdog timer