Remove redundant copies in getLevels and getFlows