Migrated codes from SandwichFlow