Simplify generated main()

...by moving some client/server functionality into libraries.
Note, at this point we could make the choice of GC library at runtime.