Refactor to handle deferred returned by flappcommand.run
checkpoint, I intend to rebase this into several

more modular commits.