memory leak with bits buffer fixed