diff -N -r -u -X .ignore gnugo-copy/engine/board.c gnugo/engine/board.c
--- gnugo-copy/engine/board.c	2007-03-07 23:04:10.203125000 +0100
+++ gnugo/engine/board.c	2007-03-07 23:04:16.015625000 +0100
@@ -1577,7 +1577,7 @@
          * conditional ko capture.
          */
         if (pos != board_ko_pos && !DIAGONAL_NEIGHBORS(kpos, kom_pos))
-	      return 0;
+	  return 0;
         break;
 
       default:
diff -N -r -u -X .ignore gnugo-copy/engine/owl.c gnugo/engine/owl.c
--- gnugo-copy/engine/owl.c	2007-03-07 23:02:12.265625000 +0100
+++ gnugo/engine/owl.c	2007-03-07 22:57:47.562500000 +0100
@@ -1359,48 +1359,54 @@
   *this_resultb = 0;
 
   if (!komaster_trymove(move, color, move_name, apos, &ko_move, ko_allowed)) {
-    /* Move was not allowed because of komaster. We want to check, if this
-     * situation is double ko and when it is, we won semeai.
-     */
-    int libs[MAX_LIBERTIES];
-    int n;
-    int nlib;
-    int sworm;
-    int worm_color;
-
-    for (sworm = 0; sworm < s_worms; sworm++) {
-      worm_color = board[semeai_worms[sworm]];
-      if (worm_color == color && *this_resulta == 0) {
-	/* We only check up to MAX_LIBERTIES, due to performance reasons. When we
-	 * have more liberties we have some outside liberties to fill and these
-	 * moves will be tried later (and double ko situation will be found).
-	 */
-	nlib = findlib(semeai_worms[sworm], MAX_LIBERTIES, libs);
-	if (nlib > MAX_LIBERTIES)
-	  return 0;
-
-	for (n = 0; n < nlib; n++)
-	  if (is_ko(libs[n], OTHER_COLOR(color), NULL)) {
-	    /* Our dragon has double ko, but we have to check if opponent dragon
-	     * doesn't have outside liberties or double ko.
-	     */
-	    *this_resulta = WIN;
-	    *this_resultb = WIN;
-	  }
-      }
-      else if (worm_color == OTHER_COLOR(color)) {
-	nlib = findlib(semeai_worms[sworm], 2, libs);
-	if (nlib > 2)
-	  /* In double ko situation the opponent can have only
-	   * a single eye and a ko outside liberty to be sure that we
-	   * will always win double ko. */
-	  return 0;
+    int kpos;
+    if (is_ko(move, color, &kpos)) {
+      /* Move was not allowed because of komaster. We want to check, if this
+       * situation is double ko and when it is, we won semeai.
+       */
+      int libs[MAX_LIBERTIES];
+      int n;
+      int nlib;
+      int sworm;
+      int worm_color;
+      int other = OTHER_COLOR(color);
+
+      for (sworm = 0; sworm < s_worms; sworm++) {
+	worm_color = board[semeai_worms[sworm]];
+	if (worm_color == color) {
+	  /* We only check up to MAX_LIBERTIES, due to performance reasons. When we
+	   * have more liberties we have some outside liberties to fill and these
+	   * moves will be tried later (and double ko situation will be found).
+	   */
+	  nlib = findlib(semeai_worms[sworm], MAX_LIBERTIES, libs);
+	  if (nlib > MAX_LIBERTIES)
+	    return 0;
+
+	  for (n = 0; n < nlib; n++)
+	    if (is_ko(libs[n], other, NULL)) {
+	      /* Check if situation is not a nested ko capture. */
+	      if (DIAGONAL_NEIGHBORS(libs[n], kpos))
+	        return 0;
+
+	      /* Our dragon has double ko, but we have to check if opponent dragon
+	       * doesn't have outside liberties or double ko.
+	       */
+	      *this_resulta = WIN;
+	      *this_resultb = WIN;
+	    }
+	}
+	else if (worm_color == other) {
+	  if (countlib(semeai_worms[sworm]) > 2)
+	    /* In double ko situation the opponent can have only
+	     * a single eye and a ko outside liberty to be sure that we
+	     * will always win double ko. */
+	    return 0;
+	}
       }
+      if (*this_resulta == WIN)
+	return 1;
     }
 
-    if (*this_resulta == WIN)
-      return 1;
-
     return 0;
   }
   

