Starting buffer refcount implementation.

Doesn't work yet.