Ah, I misread your original post.. In fact it now works how it was always supposed to work - it seems to me that any button listeners must get informed when the state changes, no matter whether it's turning on or off. If it didn't work like that in the past, I think that was unintentional.
Oh my god, this function is driving my insane! Every tiny tweak I make to fix one bug has led to some other stupid edge-case popping up somewhere else!
Ok, I've made one last change to avoid this situation, but no more!