Refactored a little to make the main flow simpler, pending fixing a bug with the updates not being broadcast to the replication slaves
Fixed bug where replication clients don't get updates