More refactoring and design before implementing the generator. Clarified writable-buffer reallocation strategy.