Fixed bugs with endgame