The `write()` are tough to review. I've looked at it side-by-side with the old implementation, and its looks good to me.