minor optimization so that newObject and includedKeys use the same code

New pull request due to this being added to the commit, after the previous commit had been merged into master.