Fixed stage id getting mixed up when merging flows