Correctly set buffer limits after underflow

Fixes #33