Handles the application flow.