Refactor application setup code into its own module.