Refactor upsert functionality. Split up documentInsertions and documentU...

...pserts.