Lots of refactorings to startup sequence to make it a little easier to follow and less dependent on events