Improve graphdb script, and test for presence of items before inserting them