Refactor replay-init logic into replay.cc.

Needed for #740.