Move recovery logic into modules.

Rebase into scheduling commit.
Rebase into pause commit.