Moved a bunch of init code into its own module