Add buffer support

Sorry, this PR is very messy. I'm not sure how good of a technique this is, but it adds support for the most common use case: buffers.