This commit cleans up the internal stack API to prepare it for an eventual move to using a native docker client.
This commit moves a huge chunk of the code to go. The TODO.md document indicates what is left to be done.