The code I had before was not toggling the mode on/off, whereas that is what we want to achieve. Thanks to Lasse Lindner for reporting the problem with those functions and for testing my proposed solution. This was done via a private channel and the information is shared with permission.
d679de1