I came to the same conclusion but with a somewhat different implementation. If @avdi prefers your version, I’m happy to merge in this part of the pull request.