Buffer assertion fix

The first commit adds a check to write at offset `-Infinity`.

The second consolidates write assert checks into a set of 3 functions. This also removes a few duplicate checks that existed.

The third consolidates and fixes the assert checks for the read methods.

If the seconds and third commits are too much of a change, just cherry-pick the first.

These changes currently conflict with master. I can port the patch if needed.