diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
--- gnugo-copy/engine/reading.c	2007-03-01 14:55:54.906250000 +0100
+++ gnugo/engine/reading.c	2007-03-05 12:33:43.062500000 +0100
@@ -1452,23 +1452,63 @@
   DEFEND_TRY_MOVES(0, NULL);
 
   /* If the string is a single stone and a capture would give a ko,
-   * try to defend it with ko by backfilling.
+   * try to defend it with ko by backfilling or killing neighbors
+   * (only KO_B result is possible).
    * If we don't find any defending move return LOSE and not KO_B,
    * because we'll lose this ko sooner or later.
    */
-  if (stackp <= backfill_depth
-      && countstones(str) == 1
+  if (!savecode && countstones(str) == 1
       && is_ko(lib, other, NULL)) {
+    int ko_move;
     int libs2[6];
     liberties = approxlib(lib, color, 6, libs2);
-    if (liberties <= 5) {
+    if (stackp <= backfill_depth) {
+      if (liberties > 6)
+	liberties = 6;
       for (k = 0; k < liberties; k++) {
 	int apos = libs2[k];
 	if ((liberties == 1 || !is_self_atari(apos, other))
-	    && trymove(apos, color, "defend1-C", str)) {
+	    && komaster_trymove(apos, color, "defend1-C", str,
+				&ko_move, stackp <= ko_depth)) {
 	  int acode = do_attack(str, NULL);
 	  popgo();
 	  CHECK_RESULT(savecode, savemove, acode, apos, move, "backfilling");
+	  if (savecode)
+	    break;
+	}
+      }
+    }
+
+    /* If we still haven't found defense, try to kill neighbors
+     * (see trevord:700 for example, when these moves could be
+     * helpful). */
+    if (!savecode && stackp <= break_chain_depth) {
+      int k;
+
+      /* Find neighbors of group created by filling a ko, which
+       * have up to two liberties and aren't neighbors of a ko
+       * stone.
+       */
+      trymove(lib, color, "defend1-D", str);
+      
+      break_chain_moves(lib, &moves);
+      break_chain2_efficient_moves(lib, &moves);
+
+      popgo();
+
+      order_moves(str, &moves, color, READ_FUNCTION_NAME, *move);
+
+      for (k = moves.num_tried; k < moves.num; k++) {
+	int dpos = moves.pos[k];
+	if (komaster_trymove(dpos, color, moves.message[k], str,
+			     &ko_move, stackp <= ko_depth)) {
+	  int acode = do_attack(str, NULL);
+	  popgo();
+	  CHECK_RESULT(savecode, savemove, acode, dpos, move,
+		       "defense effective");
+
+	  if (savecode)
+	    break;
 	}
       }
     }
diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
--- gnugo-copy/engine/utils.c	2007-03-02 02:11:53.218750000 +0100
+++ gnugo/engine/utils.c	2007-03-05 10:50:51.609375000 +0100
@@ -1955,14 +1955,14 @@
       (*num_my_stones) -= new_stones;
 
     for (k = 0; k < num_my_libs; k++) {
+      if (*num_libs == maxlibs)
+	break;
       if (ml[my_libs[k]])
 	continue;
       ml[my_libs[k]] = 1;
       if (do_add && (liberty_cap == 0 || num_my_libs <= liberty_cap)) {
 	libs[*num_libs] = my_libs[k];
 	(*num_libs)++;
-	if (*num_libs == maxlibs)
-	  break;
       }
     }
   }
diff -N -r -u -X .ignore gnugo-copy/regression/13x13c.tst gnugo/regression/13x13c.tst
--- gnugo-copy/regression/13x13c.tst	2007-01-19 02:14:39.228430800 +0100
+++ gnugo/regression/13x13c.tst	2007-03-04 19:37:54.250000000 +0100
@@ -65,6 +65,13 @@
 #? [G13]*
 
 # G13 is still sufficient to get a seki.
+#
+# After N6 the game could be:
+# N7 K12 G13 J13 N5 M3 L13 N4 H13 N6
+# and now white has to win extremely unforable 3 stage ko,
+# so this move could be acceptable - G13 and K12 leads to
+# the similar position - so the best move is N5, which
+# doesn't allow white making a ko.
 loadsgf games/kgs/tournament11/CrazyStone-GNU.sgf 87
 43 reg_genmove black
-#? [G13|K12]
+#? [G13|K12|N6|N5]
diff -N -r -u -X .ignore gnugo-copy/regression/owl.tst gnugo/regression/owl.tst
--- gnugo-copy/regression/owl.tst	2006-01-28 23:04:25.000000000 +0100
+++ gnugo/regression/owl.tst	2007-03-05 11:44:07.968750000 +0100
@@ -104,12 +104,14 @@
 loadsgf games/incident161.sgf 42
 28 owl_attack B8
 #? [1 C7]
+# after E9 C7 F9 there is a seki
 29 owl_defend B8
-#? [1 C7]
+#? [1 (C7|E9)]
 30 owl_attack D8
 #? [1 C7]
+# same as 29
 31 owl_defend D8
-#? [1 C7]
+#? [1 (C7|E9)]
 
 # incident 189
 loadsgf games/incident189.sgf 180
