We have a lot of duplicate code between the repo root and the v4 sub-directory. This was originally a compatibility thing, to allow this repo to be used either in module mode or not. But now everything should just be module mode, and the two versions have diverged, so we should eliminate the duplicate code and simplify the repo structure.