Refactor stages to objects instead of standalone arrays.