Added on_mode_change.