And a small bug fix for previous commit.

Forgot to add resource URI to all added URIs, that way same objects
would not be added multiple times.