Added automatic end of game detection. (issue #5)