Refactor some of the flow.