Refactored failsafe and correction to level mode

Some failsafe refactoring and a correction to level mode activation by
failsafe.