Refactored a bunch of code. The repl and command line script that
wraps it now seems to work reasonably well although I'm still not
completely happy with it.

There is also an outstanding problem with the ENV overwrites for the
database settings. What I expected to work as defaults did not
for whatever reason. Therefore these settings cannot currently
be overwritten by environment variables. I'm thinking moving forward
it might be worth explicitly wrapping the repl using java code and a
proper command line options parser.