Fixed mode-switching bug