Tidy-up main flow.