This commit cleans up the package structure, to make two new top-level packages `internal` (for internal-use packages) and `pkg` (for general shared utility code).
This commit moves a huge chunk of the code to go. The TODO.md document indicates what is left to be done.