anchor.diff:                  let neededForBothInline = neededForKeyInline + neededForValueInline
                   let neededForKeyInlineValueOverflow = neededForKeyInline + neededForValueOverflow
   
  -                // determine if we need to flush this page
  -                let available = pb.Available - sizeof<int32> // for the lastInt32
  -                let fitBothInline = (available >= neededForBothInline)
  -                let wouldFitBothInlineOnNextPage = ((pageSize - LEAF_PAGE_OVERHEAD) >= neededForBothInline)
  -                let fitKeyInlineValueOverflow = (available >= neededForKeyInlineValueOverflow)
  -                let neededForKeyOverflow = neededForKeyBase + neededForOverflowPageNumber
  -                let neededForBothOverflow = neededForKeyOverflow + neededForValueOverflow
  -                let fitBothOverflow = (available >= neededForBothOverflow)
  -                let flushThisPage = (countPairs > 0) && (not fitBothInline) && (wouldFitBothInlineOnNextPage || ( (not fitKeyInlineValueOverflow) && (not fitBothOverflow) ) )
  -
  -                if flushThisPage then
  -                    (countPairs,lastKey,nextPageNumber,boundaryPageNumber)
  -                else
  +                let maybeFlushLeaf st = 
  +                    let available = pb.Available - sizeof<int32> // for the lastInt32
  +                    let fitBothInline = (available >= neededForBothInline)
  +                    let wouldFitBothInlineOnNextPage = ((pageSize - LEAF_PAGE_OVERHEAD) >= neededForBothInline)
  +                    let fitKeyInlineValueOverflow = (available >= neededForKeyInlineValueOverflow)
  +                    let neededForKeyOverflow = neededForKeyBase + neededForOverflowPageNumber
  +                    let neededForBothOverflow = neededForKeyOverflow + neededForValueOverflow
  +                    let fitBothOverflow = (available >= neededForBothOverflow)
  +                    let flushThisPage = (st.keys.Length > 0) && (not fitBothInline) && (wouldFitBothInlineOnNextPage || ( (not fitKeyInlineValueOverflow) && (not fitBothOverflow) ) )
  +
  +                    if flushThisPage then
  +                        flushLeaf st false
  +                    else
  +                        st
  +
  +                let initLeaf (st:LeafState) =
  +                    if pb.Position = 0 then
  +                        pb.PutByte(LEAF_NODE)
  +                        pb.PutByte(0uy) // flags
  +
  +                        let prevPage = if List.isEmpty st.leaves then 0 else fst (List.head st.leaves)
  +                        pb.PutInt32 (prevPage) // prev page num.
  +                        pb.PutInt16 (0) // number of pairs in this page. zero for now. written at end.
  +                        // assert pb.Position is 8 (LEAF_PAGE_OVERHEAD - sizeof(lastInt32))
  +                        {st with keys=[];}
  +                    else
  +                        st
  +
  +                let addPairToLeaf (st:LeafState) =
  +                    let available = pb.Available - sizeof<int32> // for the lastInt32
  +                    let fitBothInline = (available >= neededForBothInline)
  +                    let wouldFitBothInlineOnNextPage = ((pageSize - LEAF_PAGE_OVERHEAD) >= neededForBothInline)
  +                    let fitKeyInlineValueOverflow = (available >= neededForKeyInlineValueOverflow)
  +                    let {nextPage=nextPageNumber;boundaryPage=boundaryPageNumber} = st
                       let (newN, newB) = 
                           if fitBothInline then
                               putKeyWithLength k
  
positive.code:     let private FLAG_ENDS_ON_BOUNDARY:byte = 4uy
  
  
      type writeParentPagesState = 
          { 
              sofar:int; 
              items:(int32*byte[]) list; 
              nextPage:int; 
              boundaryPage:int; 
              nextGeneration:(int32*byte[]) list; 
              overflows:Map<byte[],int32>;
          }
  
      let Create(fs:Stream, pageManager:IPages, csr:ICursor) :int32 = 
  
negative.code:         // maybe more than one level of them.
          // keep writing until we have written a level which has only one node,
          // which is the root node.
          if leaves.Length > 0 then
              let lastLeaf = fst leaves.[0]
              let firstLeaf = fst (List.nth leaves (leaves.Length-1)) // TODO slow
  
              let writeParentNodes children startingPageNumber startingBoundaryPageNumber =
                  // 2 for the page type and flags
  