Fixed bug where the game crashed when switching between units during movement