Proper JVM start-up and shut-down.

Also added a SystemState container so that it's possible to inspect
the running system. Ideally, everything "global" should be stored
there. We'll see.