diff --git a/engine/aftermath.c b/engine/aftermath.c
index b295a89..0d24525 100644
--- a/engine/aftermath.c
+++ b/engine/aftermath.c
@@ -1143,8 +1143,14 @@ play_aftermath(int color, SGFTree *aftermath_sgftree)
 	a->final_status[pos] = ALIVE;
     }
     else {
-      if (board[pos] == EMPTY)
+      if (board[pos] == EMPTY) {
+	int enclosing_color = examine_cavity(pos, NULL);
 	a->final_status[pos] = DAME;
+	if (enclosing_color == BLACK)
+	  a->black_area++;
+	else if (enclosing_color == WHITE)
+	  a->white_area++;
+      }
       else {
 	a->final_status[pos] = ALIVE_IN_SEKI;
 	if (board[pos] == WHITE)
diff --git a/engine/liberty.h b/engine/liberty.h
index 416cd29..2da94e2 100644
--- a/engine/liberty.h
+++ b/engine/liberty.h
@@ -333,6 +333,7 @@ void get_lively_stones(int color, signed char safe_stones[BOARDMAX]);
 int is_same_worm(int w1, int w2);
 int is_worm_origin(int w, int pos);
 void propagate_worm(int pos);
+int examine_cavity(int pos, int *edge);
 void find_cuts(void);
 void find_connections(void);
 
diff --git a/engine/worm.c b/engine/worm.c
index 55dfc7f..5fedcf9 100644
--- a/engine/worm.c
+++ b/engine/worm.c
@@ -44,7 +44,6 @@ static void change_tactical_point(int str, int move, int code,
 static void propagate_worm2(int str);
 static int genus(int str);
 static void markcomponent(int str, int pos, int mg[BOARDMAX]);
-static int examine_cavity(int pos, int *edge);
 static void cavity_recurse(int pos, int mx[BOARDMAX], 
 			   int *border_color, int *edge, int str);
 static void ping_cave(int str, int *result1,  int *result2,
@@ -1460,7 +1459,7 @@ markcomponent(int str, int pos, int mg[BOARDMAX])
  * edge in a point outside the removed string.  
  */
 
-static int
+int
 examine_cavity(int pos, int *edge)
 {
   int border_color = EMPTY;
@@ -1468,11 +1467,11 @@ examine_cavity(int pos, int *edge)
   int origin = NO_MOVE;
   
   ASSERT_ON_BOARD1(pos);
-  gg_assert(edge != NULL);
   
   memset(ml, 0, sizeof(ml));
 
-  *edge = 0;
+  if (edge)
+    *edge = 0;
 
   if (IS_STONE(board[pos]))
     origin = find_origin(pos);
@@ -1524,7 +1523,7 @@ cavity_recurse(int pos, int mx[BOARDMAX],
 
   mx[pos] = 1;
 
-  if (is_edge_vertex(pos) && board[pos] == EMPTY) 
+  if (edge && is_edge_vertex(pos) && board[pos] == EMPTY) 
     (*edge)++;
 
   /* Loop over the four neighbors. */
