Adding simple ko detection and fix end-of-game logic.