Allow different implementations of Buffer, and move a few things into a "util" package