move all the interesting code in the library as defaultMain.

Leave actual instance in the part where we use it, truly making
the shell generic.