Made the mode switching nicer. Now the window stays open when the mode
is changed