Refactor replication logic
Moves fields related to replication to their own struct, and split replication logic into smaller functions for ease of testing.
Edited by Niels Möller
Moves fields related to replication to their own struct, and split replication logic into smaller functions for ease of testing.