nginx-0.0.1-2004-01-15-20:51:49 import
diff --git a/src/core/ngx_rbtree.c b/src/core/ngx_rbtree.c
index 683920b..083ec10 100644
--- a/src/core/ngx_rbtree.c
+++ b/src/core/ngx_rbtree.c
@@ -147,8 +147,15 @@
     }
 
     if (subst == *root) {
-        /* it's the last node */
-        *root = sentinel;
+        *root = temp;
+        ngx_rbt_black(temp);
+
+        /* DEBUG stuff */
+        node->left = NULL;
+        node->right = NULL;
+        node->parent = NULL;
+        node->key = 0;
+
         return;
     }
 
@@ -197,6 +204,12 @@
         if (subst->right != sentinel) {
             subst->right->parent = subst;
         }
+
+        /* DEBUG stuff */
+        node->left = NULL;
+        node->right = NULL;
+        node->parent = NULL;
+        node->key = 0;
     }
 
     if (is_red) {