Fix critical bug with unsetMode()