Refactor the experimental reflow logic into its own file.

The reflow logic was getting pretty big and should be split out. No
functionality change.