Index: src/test/org/apache/lucene/index/TestByteSlices.java
===================================================================
--- src/test/org/apache/lucene/index/TestByteSlices.java	(revision 1006292)
+++ src/test/org/apache/lucene/index/TestByteSlices.java	(working copy)
@@ -21,7 +21,7 @@
 
 public class TestByteSlices extends LuceneTestCase {
 
-  private static class ByteBlockAllocator extends ByteBlockPool.Allocator {
+  public static class ByteBlockAllocator extends ByteBlockPool.Allocator {
     ArrayList<byte[]> freeByteBlocks = new ArrayList<byte[]>();
     
     /* Allocate another byte[] from the shared pool */
@@ -80,7 +80,7 @@
           System.out.println("write stream=" + stream);
 
         if (starts[stream] == -1) {
-          final int spot = pool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE);
+          final int spot = pool.newSliceByLevel(0);
           starts[stream] = uptos[stream] = spot + pool.byteOffset;
           if (VERBOSE)
             System.out.println("  init to " + starts[stream]);
Index: src/java/org/apache/lucene/index/ByteBlockPool.java
===================================================================
--- src/java/org/apache/lucene/index/ByteBlockPool.java	(revision 1006292)
+++ src/java/org/apache/lucene/index/ByteBlockPool.java	(working copy)
@@ -52,6 +52,8 @@
   int bufferUpto = -1;                        // Which buffer we are upto
   public int byteUpto = DocumentsWriterRAMAllocator.BYTE_BLOCK_SIZE;             // Where we are in head buffer
 
+  public int byteSliceUpto = DocumentsWriterRAMAllocator.BYTE_BLOCK_SIZE;
+  
   public byte[] buffer;                              // Current head buffer
   public int byteOffset = -DocumentsWriterRAMAllocator.BYTE_BLOCK_SIZE;          // Current head offset
 
@@ -80,6 +82,7 @@
       bufferUpto = 0;
       byteUpto = 0;
       byteOffset = 0;
+      byteSliceUpto = 0;
       buffer = buffers[0];
     }
   }
@@ -95,15 +98,21 @@
     bufferUpto++;
 
     byteUpto = 0;
+    byteSliceUpto = 0;
     byteOffset += DocumentsWriterRAMAllocator.BYTE_BLOCK_SIZE;
   }
 
-  public int newSlice(final int size) {
+  public int newSliceByLevel(final int level) {
+    int size = levelSizeArray[level];
     if (byteUpto > DocumentsWriterRAMAllocator.BYTE_BLOCK_SIZE-size)
       nextBuffer();
     final int upto = byteUpto;
+    
     byteUpto += size;
-    buffer[byteUpto-1] = 16;
+    
+    byteSliceUpto = byteUpto - 3;
+    
+    buffer[byteSliceUpto-1] = 16;
     return upto;
   }
 
@@ -113,9 +122,9 @@
   // array is the length of each slice, ie first slice is 5
   // bytes, next slice is 14 bytes, etc.
   final static int[] nextLevelArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 9};
-  final static int[] levelSizeArray = {5, 14, 20, 30, 40, 40, 80, 80, 120, 200};
+  final static int[] levelSizeArray = {9, 14, 20, 30, 40, 40, 80, 80, 120, 200};
   final static int FIRST_LEVEL_SIZE = levelSizeArray[0];
-
+  
   public int allocSlice(final byte[] slice, final int upto) {
 
     final int level = slice[upto] & 15;
@@ -127,25 +136,21 @@
       nextBuffer();
 
     final int newUpto = byteUpto;
-    final int offset = newUpto + byteOffset;
+    final int offset = byteUpto + byteOffset;
+    
     byteUpto += newSize;
-
-    // Copy forward the past 3 bytes (which we are about
-    // to overwrite with the forwarding address):
-    buffer[newUpto] = slice[upto-3];
-    buffer[newUpto+1] = slice[upto-2];
-    buffer[newUpto+2] = slice[upto-1];
-
-    // Write forwarding address at end of last slice:
-    slice[upto-3] = (byte) (offset >>> 24);
-    slice[upto-2] = (byte) (offset >>> 16);
-    slice[upto-1] = (byte) (offset >>> 8);
-    slice[upto] = (byte) offset;
-        
+    
+    slice[upto] = (byte) (offset >>> 24);
+    slice[upto+1] = (byte) (offset >>> 16);
+    slice[upto+2] = (byte) (offset >>> 8);
+    slice[upto+3] = (byte) offset;
+    
+    byteSliceUpto = byteUpto - 3;
+    
     // Write new level:
-    buffer[byteUpto-1] = (byte) (16|newLevel);
+    buffer[byteSliceUpto-1] = (byte) (16|newLevel);
 
-    return newUpto+3;
+    return newUpto;
   }
 
   // Fill in a BytesRef from term's length & bytes encoded in
Index: src/java/org/apache/lucene/index/TermsHashPerField.java
===================================================================
--- src/java/org/apache/lucene/index/TermsHashPerField.java	(revision 1006292)
+++ src/java/org/apache/lucene/index/TermsHashPerField.java	(working copy)
@@ -368,7 +368,7 @@
       postingsArray.intStarts[termID] = intUptoStart + intPool.intOffset;
 
       for(int i=0;i<streamCount;i++) {
-        final int upto = bytePool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE);
+        final int upto = bytePool.newSliceByLevel(0);
         intUptos[intUptoStart+i] = upto + bytePool.byteOffset;
       }
       postingsArray.byteStarts[termID] = intUptos[intUptoStart];
@@ -496,7 +496,7 @@
       postingsArray.intStarts[termID] = intUptoStart + intPool.intOffset;
 
       for(int i=0;i<streamCount;i++) {
-        final int upto = bytePool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE);
+        final int upto = bytePool.newSliceByLevel(0);
         intUptos[intUptoStart+i] = upto + bytePool.byteOffset;
       }
       postingsArray.byteStarts[termID] = intUptos[intUptoStart];
