Index: kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php
===================================================================
--- kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	(revision 22507)
+++ kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	(working copy)
@@ -167,14 +167,15 @@
         else
             $parentParams['section_level']++;
 
-        // init header counter for current level and resert it for the next level
+        // init header counter for current level and for the next level if needed
         $level = $parentParams['section_level'];
         if ( $level != 0 )
         {
             if ( !isset( $this->HeaderCount[$level] ) )
                 $this->HeaderCount[$level] = 0;
 
-            $this->HeaderCount[$level + 1] = 0;
+            if ( !isset( $this->HeaderCount[$level + 1] ) )
+                $this->HeaderCount[$level + 1] = 0;
         }
 
         return $ret;
Index: kernel/common/eztocoperator.php
===================================================================
--- kernel/common/eztocoperator.php	(revision 22507)
+++ kernel/common/eztocoperator.php	(working copy)
@@ -110,7 +110,10 @@
     function handleSection( $sectionNode, $level = 0 )
     {
         // Reset next level counter
-        $this->HeaderCounter[$level + 1] = 0;
+        if ( !isset( $this->HeaderCounter[$level + 1] ) )
+        {
+            $this->HeaderCounter[$level + 1] = 0;
+        }
 
         $tocText = '';
         $children = $sectionNode->childNodes;
