Implemented endgame (closes #5)