It seems that most of this logic didn't end up changing at all (except for maybe a `write` => `write_char`). Would you mind rebasing out these changes to minimize the diff impact?