Added error handling for duplicate IDs and fixed support of custom _id's...

....