diff -N -r -u -X .ignore gnugo-copy/engine/matchpat.c gnugo/engine/matchpat.c
--- gnugo-copy/engine/matchpat.c	2006-10-27 16:43:26.000000000 +0200
+++ gnugo/engine/matchpat.c	2007-02-04 15:52:52.890625000 +0100
@@ -2,7 +2,7 @@
  * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see       *
  * http://www.gnu.org/software/gnugo/ for more information.          *
  *                                                                   *
- * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006       *
+ * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 *
  * by the Free Software Foundation.                                  *
  *                                                                   *
  * This program is free software; you can redistribute it and/or     *
@@ -135,7 +135,7 @@
 
 /* Forward declarations. */
 
-static void fixup_patterns_for_board_size(struct pattern *pattern);
+static void fixup_patterns_for_board_size(struct pattern_db *pdb);
 static void prepare_for_match(int color);
 static void do_matchpat(int anchor, matchpat_callback_fn_ptr callback,
 			int color, struct pattern *database,
@@ -214,8 +214,11 @@
  */
 
 static void
-fixup_patterns_for_board_size(struct pattern *pattern)
+fixup_patterns_for_board_size(struct pattern_db *pdb)
 {
+  struct pattern *pattern = pdb->patterns;
+  int undo = pdb->fixed_for_size != -1;
+
   for (; pattern->patn; ++pattern)
     if (pattern->edge_constraints != 0) {
 
@@ -225,17 +228,19 @@
        * called, this step is effectively a no-op.
        */
       
-      if (pattern->edge_constraints & NORTH_EDGE)
-	pattern->maxi = pattern->mini + pattern->height;
+      if (undo) {
+	if (pattern->edge_constraints & NORTH_EDGE)
+	  pattern->maxi = pattern->mini + pattern->height;
 	
-      if (pattern->edge_constraints & SOUTH_EDGE)
-	pattern->mini = pattern->maxi - pattern->height;
+	if (pattern->edge_constraints & SOUTH_EDGE)
+	  pattern->mini = pattern->maxi - pattern->height;
 	
-      if (pattern->edge_constraints & WEST_EDGE)
-	pattern->maxj = pattern->minj + pattern->width;
+	if (pattern->edge_constraints & WEST_EDGE)
+	  pattern->maxj = pattern->minj + pattern->width;
       
-      if (pattern->edge_constraints & EAST_EDGE)
-	pattern->minj = pattern->maxj - pattern->width;
+	if (pattern->edge_constraints & EAST_EDGE)
+	  pattern->minj = pattern->maxj - pattern->width;
+      }
       
       /* we extend the pattern in the direction opposite the constraint,
        * such that maxi (+ve) - mini (-ve) = board_size-1
@@ -342,7 +347,7 @@
     {
       int end_transformation;
       int ll;   /* Iterate over transformations (rotations or reflections)  */
-      int k;    /* Iterate over elements of pattern */
+      struct patval *elpat, *elend;    /* Iterate over elements of pattern */
       int found_goal;
   
       /* We can check the color of the anchor stone now.
@@ -365,14 +370,15 @@
       if (anchor_test != pattern->anchored_at_X)
 	continue;  /* does not match the anchor */
 
-      ll = 0;  /* first transformation number */
-      end_transformation = pattern->trfno;
-
       /* Ugly trick for dealing with 'O' symmetry. */
       if (pattern->trfno == 5) {
 	ll = 2;
 	end_transformation = 6;
       }
+      else {
+	ll = 0;  /* first transformation number */
+	end_transformation = pattern->trfno;
+      }
       
       /* try each orientation transformation. Assume at least 1 */
 
@@ -425,15 +431,18 @@
 	}
 
 	/* Now iterate over the elements of the pattern. */
-	found_goal = 0;
-	for (k = 0; k < pattern->patlen; ++k) { /* match each point */
+	found_goal = (goal == NULL);
+
+	elpat = pattern->patn;
+	elend = elpat + pattern->patlen;
+	for (; elpat < elend; ++elpat) { /* match each point */
 	  int pos; /* absolute coords of (transformed) pattern element */
-	  int att = pattern->patn[k].att;  /* what we are looking for */
+	  int att = elpat->att;  /* what we are looking for */
 
 	  /* Work out the position on the board of this pattern element. */
 
 	  /* transform pattern real coordinate... */
-	  pos = AFFINE_TRANSFORM(pattern->patn[k].offset, ll, anchor);
+	  pos = AFFINE_TRANSFORM(elpat->offset, ll, anchor);
 
 	  ASSERT_ON_BOARD1(pos);
 
@@ -441,7 +450,7 @@
 	  if ((board[pos] & and_mask[color-1][att]) != val_mask[color-1][att])
 	    goto match_failed;
 
-	  if (goal != NULL && board[pos] != EMPTY && goal[pos])
+	  if (!found_goal && board[pos] && goal[pos])
 	    found_goal = 1;
 	  
 	  /* Check out the class_X, class_O, class_x, class_o
@@ -463,7 +472,7 @@
 
 
 	/* Make it here ==> We have matched all the elements to the board. */
-	if ((goal != NULL) && !found_goal)
+	if (!found_goal)
 	  goto match_failed;
 
 #if PROFILE_PATTERNS
@@ -485,7 +494,7 @@
 	      pattern->name, ll, anchor);
 	 
       } while (++ll < end_transformation); /* ll loop over symmetries */
-    } /* if not rejected by maxwt */
+    }
   } while ((++pattern)->patn);  /* loop over patterns */
 }
 
@@ -493,7 +502,7 @@
 /*
  * Scan the board to get patterns anchored by anchor from color
  * point of view.
- * the board must be prepared by dfa_prepare_for_match(color) !
+ * the board must be prepared by prepare_for_match(color) !
  */
 static void
 matchpat_loop(matchpat_callback_fn_ptr callback, int color, int anchor,
@@ -503,7 +512,7 @@
   int pos;
   
   for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
-    if (board[pos] == anchor && (!anchor_in_goal || goal[pos] != 0))
+    if (board[pos] == anchor && (!anchor_in_goal || goal[pos]))
       do_matchpat(pos, callback, color, pdb->patterns,
 		  callback_data, goal);
   }
@@ -537,14 +546,12 @@
 static void do_dfa_matchpat(dfa_rt_t *pdfa,
 			    int anchor, matchpat_callback_fn_ptr callback,
 			    int color, struct pattern *database,
-			    void *callback_data, signed char goal[BOARDMAX],
-                            int anchor_in_goal);
+			    void *callback_data, signed char goal[BOARDMAX]);
 static void check_pattern_light(int anchor, 
 				matchpat_callback_fn_ptr callback,
 				int color, struct pattern *pattern, int ll,
 				void *callback_data,
-				signed char goal[BOARDMAX],
-                                int anchor_in_goal);
+				signed char goal[BOARDMAX]);
 static void dfa_matchpat_loop(matchpat_callback_fn_ptr callback,
 			      int color, int anchor,
 			      struct pattern_db *pdb, void *callback_data,
@@ -643,26 +650,25 @@
 scan_for_patterns(dfa_rt_t *pdfa, int l, int *dfa_pos, int *pat_list)
 {
   int delta;
-  int state = 1; /* initial state */
+  const state_rt_t *state = pdfa->states + 1; /* initial state */
   int row = 0; /* initial row */
   int id = 0; /* position in id_list */
 
-  do {
+  for (;;) {
     /* collect patterns indexes */
-    int att = pdfa->states[state].att;
+    int att = state->att;
     while (att != 0) {
-      pat_list[id] = pdfa->indexes[att].val;
-      id++;
+      pat_list[id++] = pdfa->indexes[att].val;
       att = pdfa->indexes[att].next;
     }
 
     /* go to next state */
-    delta = pdfa->states[state].next[dfa_pos[spiral[row][l]]];
-    state += delta;
-    row++;
-  } while (delta != 0); /* while not on error state */
+    delta = state->next[*(dfa_pos + spiral[row++][l])];
+    if (!delta)
+      return id; /* error state */
 
-  return id;
+    state += delta;
+  }
 }
 
 
@@ -671,12 +677,12 @@
 do_dfa_matchpat(dfa_rt_t *pdfa,
 		int anchor, matchpat_callback_fn_ptr callback,
 		int color, struct pattern *database,
-		void *callback_data, signed char goal[BOARDMAX],
-		int anchor_in_goal)
+		void *callback_data, signed char goal[BOARDMAX])
 {
   int k;
   int ll;      /* Iterate over transformations (rotations or reflections)  */
-  int patterns[DFA_MAX_MATCHED + 8];
+  int patterns[DFA_MAX_MATCHED + 8]; /* Reserve 8 for -1 value
+				      * (a transformation separator). */
   int num_matched = 0;
   int *dfa_pos = dfa_p + DFA_POS(I(anchor), J(anchor));
 
@@ -694,21 +700,31 @@
 
   /* Constraints and other tests. */
   for (ll = 0, k = 0; ll < 8; k++) {
-    int matched;
+    struct pattern *matched;
 
     if (patterns[k] == -1) {
       ll++;
       continue;
     }
 
-    matched = patterns[k];
+    matched = database + patterns[k];
 
 #if PROFILE_PATTERNS
-    database[matched].dfa_hits++;
+    matched->dfa_hits++;
 #endif
 
-    check_pattern_light(anchor, callback, color, database + matched,
-			ll, callback_data, goal, anchor_in_goal);
+    /* Throw out duplicating orientations of symmetric patterns. */
+    if (matched->trfno == 5) {
+      if (ll < 2 || ll >= 6)
+	continue;
+    }
+    else {
+      if (ll >= matched->trfno)
+	continue;
+    }
+
+    check_pattern_light(anchor, callback, color, matched,
+			ll, callback_data, goal);
   }
 }
 
@@ -722,31 +738,21 @@
 static void
 check_pattern_light(int anchor, matchpat_callback_fn_ptr callback, int color,
 		    struct pattern *pattern, int ll, void *callback_data,
-		    signed char goal[BOARDMAX], int anchor_in_goal)
+		    signed char goal[BOARDMAX])
 {
   int k;			/* Iterate over elements of pattern */
-  int found_goal = 0;
+  int found_goal = (goal == NULL);
   
 #if PROFILE_PATTERNS
   int nodes_before;
 #endif
   
-  if (0)
-    gprintf("check_pattern_light @ %1m rot:%d pattern: %s\n", 
-	    anchor, ll, pattern->name);
-
-  /* Throw out duplicating orientations of symmetric patterns. */
-  if (pattern->trfno == 5) {
-    if (ll < 2 || ll >= 6)
-      return;
-  }
-  else {
-    if (ll >= pattern->trfno)
-      return;
-  }
+#if 0
+  gprintf("check_pattern_light @ %1m rot:%d pattern: %s\n", 
+	  anchor, ll, pattern->name);
+#endif
 
- 
-  /* Now iterate over the elements of the pattern. */
+  /* Iterate over the elements of the pattern. */
   for (k = 0; k < pattern->patlen; k++) {
   				/* match each point */
     int pos;			/* absolute (board) co-ords of 
@@ -756,11 +762,9 @@
     pos = AFFINE_TRANSFORM(pattern->patn[k].offset, ll, anchor);
     ASSERT_ON_BOARD1(pos);
 
-    if (!anchor_in_goal) { 
-      /* goal check */
-      if (goal != NULL && board[pos] != EMPTY && goal[pos])
-	found_goal = 1;
-    }
+    /* goal check */
+    if (!found_goal && board[pos] && goal[pos])
+      found_goal = 1;
 
     /* class check */
     ASSERT1(dragon[pos].status < 4, anchor);
@@ -770,10 +774,8 @@
   } /* loop over elements */
   
   /* Make it here ==> We have matched all the elements to the board. */
-  if (!anchor_in_goal) { 
-    if (goal != NULL && !found_goal)
-      goto match_failed;
-  }
+  if (!found_goal)
+    goto match_failed;
 
 #if PROFILE_PATTERNS
   pattern->hits++;
@@ -808,9 +810,9 @@
   int pos;
 
   for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
-    if (board[pos] == anchor && (!anchor_in_goal || goal[pos] != 0))
+    if (board[pos] == anchor && (!anchor_in_goal || goal[pos]))
       do_dfa_matchpat(pdb->pdfa, pos, callback, color, pdb->patterns,
-		      callback_data, goal, anchor_in_goal);
+		      callback_data, goal);
   }
 }
 
@@ -852,12 +854,12 @@
 		     struct pattern_db *pdb, void *callback_data,
 		     signed char goal[BOARDMAX], int anchor_in_goal) 
 {
-  loop_fn_ptr_t loop = matchpat_loop;
-  prepare_fn_ptr_t prepare = prepare_for_match;
+  loop_fn_ptr_t loop;
+  prepare_fn_ptr_t prepare;
 
   /* check board size */
   if (pdb->fixed_for_size != board_size) {
-    fixup_patterns_for_board_size(pdb->patterns);
+    fixup_patterns_for_board_size(pdb);
     pdb->fixed_for_size = board_size;
   }
 
@@ -866,11 +868,16 @@
     loop = dfa_matchpat_loop;
     prepare = dfa_prepare_for_match;
   }
+  else {
+    loop = matchpat_loop;
+    prepare = prepare_for_match;
+  }
 
   /* select strategy */
   switch (color) {
     case ANCHOR_COLOR:
-      { /* match pattern for the color of their anchor */
+      { /* match patterns for the color of their anchor; patterns must be
+	 * compiled to always anchor our color */
 	prepare(WHITE);
 	loop(callback, WHITE, WHITE, pdb, callback_data, goal, anchor_in_goal);
 	prepare(BLACK);
@@ -878,7 +885,8 @@
       }
       break;
     case ANCHOR_OTHER:
-      { /* match pattern for the opposite color of their anchor */
+      { /* match patterns for the opposite color of their anchor; patterns must
+	 * be compiled to always anchor the opposite color */
 	prepare(WHITE);
 	loop(callback, WHITE, BLACK, pdb, callback_data, goal, anchor_in_goal);
 	prepare(BLACK);
@@ -896,14 +904,14 @@
 
 
 static int
-fullboard_transform(int pos, int trans)
+fullboard_transform(int pos, int trans, int half_board)
 {
-  int dx = I(pos) - (board_size-1)/2;
-  int dy = J(pos) - (board_size-1)/2;
+  int dx = I(pos) - half_board;
+  int dy = J(pos) - half_board;
   int x, y;
-  gg_assert(POS((board_size-1)/2, (board_size-1)/2) + DELTA(dx, dy) == pos);
+  gg_assert(POS(half_board, half_board) + DELTA(dx, dy) == pos);
   TRANSFORM2(dx, dy, &x, &y, trans);
-  return POS(x + (board_size-1)/2, y + (board_size-1)/2);
+  return POS(x + half_board, y + half_board);
 }
 
 /* A dedicated matcher which can only do fullboard matching on
@@ -919,6 +927,8 @@
   static int color_map[gg_max(WHITE, BLACK) + 1];
   /* One hash value for each rotation/reflection: */
   Hash_data current_board_hash[8];
+  int half_board = (board_size-1)/2;
+  int half_board_pos = POS(half_board, half_board);
   
   /* Basic sanity check. */
   gg_assert(color != EMPTY);
@@ -936,17 +946,17 @@
 
   /* Get hash data of all rotations/reflections of current board position. */
   for (ll = 0; ll < 8; ll++) {
-    Intersection p[BOARDSIZE];
+    Intersection p[BOARDMAX];
     int pos;
-    for (pos = 0; pos < BOARDSIZE; pos++)
+    for (pos = BOARDMIN; pos < BOARDMAX; pos++)
       if (ON_BOARD(pos))
-	p[pos] = color_map[board[fullboard_transform(pos, ll)]];
+	p[pos] = color_map[board[fullboard_transform(pos, ll, half_board)]];
       else
 	p[pos] = GRAY;
 
     if (ON_BOARD(board_ko_pos))
       hashdata_recalc(&current_board_hash[ll], p,
-		      fullboard_transform(board_ko_pos, ll));
+		      fullboard_transform(board_ko_pos, ll, half_board));
     else 
       hashdata_recalc(&current_board_hash[ll], p, NO_MOVE);
   }
@@ -959,8 +969,7 @@
     for (ll = 0; ll < 8; ll++)
       if (hashdata_is_equal(current_board_hash[ll], pattern->fullboard_hash)) {
 	/* A match!  - Call back to the invoker to let it know. */
-	int pos = AFFINE_TRANSFORM(pattern->move_offset, ll,
-			           POS((board_size-1)/2, (board_size-1)/2));
+	int pos = AFFINE_TRANSFORM(pattern->move_offset, ll, half_board_pos);
 	callback(pos, pattern, ll);
       }
   }
@@ -1012,7 +1021,7 @@
 		   int match_color, corner_matchpat_callback_fn_ptr callback,
 		   int callback_color, int trans, int anchor, int stones)
 {
-  for (; --num_variations >= 0; variation++) {
+  for (; num_variations--; variation++) {
     int move = AFFINE_TRANSFORM(variation->move_offset, trans, anchor);
     int color_check = match_color ^ variation->xor_att;
     struct corner_pattern *pattern = variation->pattern;
@@ -1062,12 +1071,14 @@
     int dx = TRANSFORM(OFFSET(1, 0), k);
     int dy = TRANSFORM(OFFSET(0, 1), k);
     int pos;
+    int prev_stones;
     struct corner_variation *variation = database->top_variations;
 
     /* Fill in the NUM_STONES() array. We use `max_width' and `max_height'
      * fields of database structure to stop working as early as possible.
      */
-    NUM_STONES(anchor) = IS_STONE(board[anchor]);
+    prev_stones = IS_STONE(board[anchor]);
+    NUM_STONES(anchor) = prev_stones;
 
     pos = anchor;
     for (i = 1; i < database->max_height; i++) {
@@ -1081,10 +1092,13 @@
 	break;
       }
 
-      NUM_STONES(pos) = NUM_STONES(pos - dx) + IS_STONE(board[pos]);
+      prev_stones += IS_STONE(board[pos]);
+      NUM_STONES(pos) = prev_stones;
     }
 
     pos = anchor;
+    prev_stones = NUM_STONES(anchor);
+
     for (j = 1; j < database->max_width; j++) {
       pos += dy;
       if (!ON_BOARD(pos)) {
@@ -1096,17 +1110,19 @@
 	break;
       }
       
-      NUM_STONES(pos) = NUM_STONES(pos - dy) + IS_STONE(board[pos]);
+      prev_stones += IS_STONE(board[pos]);
+      NUM_STONES(pos) = prev_stones;
     }
     
     for (i = 1; i < database->max_height; i++) {
       pos = anchor + i * dy;
+      prev_stones = NUM_STONES(pos);
       for (j = 1; j < database->max_width; j++) {
 	pos += dx;
-	NUM_STONES(pos) = NUM_STONES(pos - dx) + NUM_STONES(pos - dy)
-			- NUM_STONES(pos - dx - dy);
+	prev_stones += NUM_STONES(pos - dy) - NUM_STONES(pos - dx - dy);
 	if (ON_BOARD1(pos) && IS_STONE(board[pos]))
-	  NUM_STONES(pos)++;
+	  prev_stones++;
+	NUM_STONES(pos) = prev_stones;
       }
     }
 
diff -N -r -u -X .ignore gnugo-copy/patterns/attack.db gnugo/patterns/attack.db
--- gnugo-copy/patterns/attack.db	2006-01-23 19:15:50.000000000 +0100
+++ gnugo/patterns/attack.db	2007-02-01 12:58:22.625000000 +0100
@@ -54,7 +54,7 @@
 # Even if a ladder works (and is found by the tactical reading) we
 # also want to consider the geta capture.
 
-XOO?    capture one stone
+?OO?    capture one stone
 OX..
 O.*?
 ?.??
diff -N -r -u -X .ignore gnugo-copy/patterns/defense.db gnugo/patterns/defense.db
--- gnugo-copy/patterns/defense.db	2006-01-23 19:15:50.000000000 +0100
+++ gnugo/patterns/defense.db	2007-01-31 11:18:01.656250000 +0100
@@ -80,7 +80,7 @@
 
 Pattern Def4
 
-XOO?    capture one stone
+?OO?    capture one stone
 OX..
 O.*?
 ?.??
diff -N -r -u -X .ignore gnugo-copy/patterns/dfa.h gnugo/patterns/dfa.h
--- gnugo-copy/patterns/dfa.h	2006-01-23 19:15:50.000000000 +0100
+++ gnugo/patterns/dfa.h	2007-02-02 18:57:49.031250000 +0100
@@ -2,7 +2,7 @@
  * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see       *
  * http://www.gnu.org/software/gnugo/ for more information.          *
  *                                                                   *
- * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006       *
+ * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 *
  * by the Free Software Foundation.                                  *
  *                                                                   *
  * This program is free software; you can redistribute it and/or     *
@@ -24,13 +24,24 @@
 #define _DFA_H_
 
 
+/* We must leave DFA_MAX_BOARD reserve on each side, because moving
+ * through the board with spiral order could throw us outside the
+ * board up to DFA_MAX_BOARD intersections.
+ */
 #define DFA_MAX_BOARD		MAX_BOARD
-#define DFA_MAX_ORDER		((2 * DFA_MAX_BOARD - 1)	\
-				 * (2 * DFA_MAX_BOARD - 1))
 #define DFA_BASE		(3 * DFA_MAX_BOARD)
 #define DFA_POS(i, j)		(((i) + DFA_MAX_BOARD) * DFA_BASE	\
 				 + ((j) + DFA_MAX_BOARD))
 
+/* Spiral order looks like rectangle. If a pattern anchor is at the
+ * corner of the board and we want to be sure that pattern can match
+ * whole board, spiral order must be rectangle of side sized
+ * 2 * DFA_MAX_BOARD - 1, because anchor is in the middle of this
+ * rectangle.
+ */
+#define DFA_MAX_ORDER		((2 * DFA_MAX_BOARD - 1)	\
+				 * (2 * DFA_MAX_BOARD - 1))
+
 #ifndef EMPTY
 #define EMPTY     0		/* . */
 #define WHITE     1		/* O */
@@ -39,11 +50,13 @@
 #define OUT_BOARD 3		/* # */
 
 
-/* Maximum pattern matched at one positions. */
+/* Maximum patterns matched at one position - 8 transformations
+ * (24 is an arbitrary value).
+ */
 #define DFA_MAX_MATCHED		(8 * 24)
 
 
-/* DFA spiral order. */
+/* DFA spiral order (for each transformation). */
 extern int spiral[DFA_MAX_ORDER][8];
 
 void build_spiral_order(void);
@@ -55,15 +68,15 @@
 /* Attribute list. */
 typedef struct attrib_rt
 {
-  short val;
-  short next;
+  short val;  /* Number of a matched pattern. */
+  short next; /* Same position could match to more than one pattern. */
 } attrib_rt_t;
 
 /* DFA state. */
 typedef struct state_rt
 {
-  short next[4];
-  short att;
+  short next[4]; /* Next state to jump to. */
+  short att;     /* An index in the attributes table. */
 } state_rt_t;
 
 typedef struct dfa_rt
diff -N -r -u -X .ignore gnugo-copy/patterns/patterns.h gnugo/patterns/patterns.h
--- gnugo-copy/patterns/patterns.h	2006-01-23 19:15:50.000000000 +0100
+++ gnugo/patterns/patterns.h	2007-02-04 14:20:03.375000000 +0100
@@ -1,8 +1,8 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\\
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
  * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see       *
  * http://www.gnu.org/software/gnugo/ for more information.          *
  *                                                                   *
- * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006       *
+ * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 *
  * by the Free Software Foundation.                                  *
  *                                                                   *
  * This program is free software; you can redistribute it and/or     *
@@ -119,9 +119,9 @@
  * patterns.db and other databases which are handled by shapes.c.
  */
 #define CLASS_O     0x0001   /* O stones must be alive or unknown */
-#define CLASS_o     0x0002   /* O stones must be dead or unknown */
-#define CLASS_X     0x0004   /* X stones must be alive or unknown */
-#define CLASS_x     0x0008   /* X stones must be dead or unknown */
+#define CLASS_o     0x0002   /* O stones must be dead, critical or unknown */
+#define CLASS_X     0x0004   /* X stones must be alive, critical or unknown */
+#define CLASS_x     0x0008   /* X stones must be dead, critical or unknown */
 #define CLASS_s     0x0010   /* move is a sacrifice */
 #define CLASS_n     0x0020   /* X could also make this move if we do not */
 #define CLASS_D     0x0040   /* defense pattern */
@@ -230,7 +230,11 @@
  * Each pattern as a whole is compiled to an instance of this structure.
  */
 struct pattern {
-  struct patval *patn;  /* array of elements */
+  struct patval *patn;  /* array of elements; some of them can be filtered due to
+			 * grid optimization (these are 9 elements around an
+			 * anchor) or usage of the dfa matcher (which doesn't need
+			 * elements at all) - except these needed by: goal checking,
+			 * dragon status checking or a callback function */
   int patlen;           /* number of elements */
   int trfno;            /* number of transformations (rotations and reflections) */
   const char *name;     /* short description of pattern (optional) */
