Refactor upsert functionality. Split up documentInsertions and documentUpserts.