Improve buffer_capture_write