Move more app startup code to main module.