Refactoring of various internal APIs, particularly those dealing with replicating documents with attachments.