New buffering implementation. Closes #79.
Implemented boundary checking for the buffering.