Copied implementation into libraries.

  This is in-progress work which moves the packages we use into
 modular code.

  The intention is actually that we'll install the script by
 concatenating the various library-modules into a single script.

  They're broken up more so that we can load the modules
 indivudually by our test-suite.