Fixed the mode switching.