Move some replication processing out of `generic_worker`.