Move primaryKey injection earlier

Fixes #91. Move primaryKey injection earlier so it can successfully find/merge duplicate objects within a response.  This involved a bit of refactoring to do cleanly.