Improved main workflow.