Fixed bug when changing modes