Fixed: HandleStateChange is now called in the game loop