Fixed major bug in endgame