Checkmate and stalemate now work properly.
Still to do: special moves, promotion and multi-game support.