Refactoring, encoding, and buffers