(Untested) possible fix for random crashes with new mode switching mechanic