Make sure we are finished with a buffer before freeing it.

This may block on deallocation, but it is better than crashing.
Add comments marking overflow checks.