Re-factored app initialization.