WriteBuf bug fix