Fixed end game detection. Still needs work.