Move FlexE logic from main to a FlexE object.