Fixed bugs at end game