Flatten some control flow to prepare for rearranging.

(It may look like I'm making random changes, but I'm preparing the code to move to a single point where we resume execution.)