Added failsafe switch and other minor changes