Added stalemate detection