fixed bug where you'd go into infinite loop when game ended + small improvements