anchor.diff:                  let v = csr.Value()
                   // assert k <> null
                   // but v might be null (a tombstone)
  +
                   let vlen = if v<>null then v.Length else int64 0
   
                   let neededForOverflowPageNumber = sizeof<int32>
   
                   let neededForKeyBase = 1 + Varint.SpaceNeededFor(int64 k.Length)
                   let neededForKeyInline = neededForKeyBase + k.Length
  -                let neededForKeyOverflow = neededForKeyBase + neededForOverflowPageNumber
   
                   let neededForValueInline = 1 + if v<>null then Varint.SpaceNeededFor(int64 vlen) + int vlen else 0
                   let neededForValueOverflow = 1 + if v<>null then Varint.SpaceNeededFor(int64 vlen) + neededForOverflowPageNumber else 0
   
                   let neededForBothInline = neededForKeyInline + neededForValueInline
                   let neededForKeyInlineValueOverflow = neededForKeyInline + neededForValueOverflow
  -                let neededForBothOverflow = neededForKeyOverflow + neededForValueOverflow
   
                   csr.Next()
   
                   if pb.Position > 0 then
  -                    let avail = pb.Available - sizeof<int32> // for the lastInt32
  -                    let fitBothInline = (avail >= neededForBothInline)
  -                    let wouldFitBothInlineOnNextPage = ((pb.PageSize - LEAF_PAGE_OVERHEAD) >= neededForBothInline)
  -                    let fitKeyInlineValueOverflow = (avail >= neededForKeyInlineValueOverflow)
  -                    let fitBothOverflow = (avail >= neededForBothOverflow)
  +                    // determine if we need to flush this page
  +                    let spaceLeft = pb.Available - sizeof<int32> // for the lastInt32
  +                    let fitBothInline = (spaceLeft >= neededForBothInline)
  +                    let wouldFitBothInlineOnNextPage = ((pageSize - LEAF_PAGE_OVERHEAD) >= neededForBothInline)
  +                    let fitKeyInlineValueOverflow = (spaceLeft >= neededForKeyInlineValueOverflow)
  +                    let neededForKeyOverflow = neededForKeyBase + neededForOverflowPageNumber
  +                    let neededForBothOverflow = neededForKeyOverflow + neededForValueOverflow
  +                    let fitBothOverflow = (spaceLeft >= neededForBothOverflow)
                       let flushThisPage = (not fitBothInline) && (wouldFitBothInlineOnNextPage || ( (not fitKeyInlineValueOverflow) && (not fitBothOverflow) ) )
   
                       if flushThisPage then
  
positive.code:                     if (not isRootPage) && (thisPageNumber = boundaryPageNumber) then
                          pb.SetPageFlag FLAG_BOUNDARY_NODE
                          let newRange = pageManager.GetRange(token)
                          // assert pb.Position <= (pb.PageSize - 4)
                          pb.SetLastInt32(fst newRange)
                          newRange
                      else
  
negative.code:                         let (nextPage,boundaryPage) = flushLeaf countPairs lastKey nextPageNumber boundaryPageNumber
                          nextPageNumber <- nextPage
                          boundaryPageNumber <- boundaryPage
  
                  if pb.Position = 0 then
                      // we are here either because we just flushed a page
  