Fix some potentially bad behaviours when switching.