This reverts commit 8cdd23dda2add6486abb685834def94c72a09b6c.
Refactoring continues. This update moves some of the replication manipulation functions to a separate file and turns them into class methods.