Changed pack function to rotate cyclic buffer