Fix some crashes when switching rendering mode.