-Corrected empty buffer calculations (flipped head/tail)