Only do a single realloc in append_buffer, thanks to @msoucy for pointing out that inefficency