Fixed a bug that allowed the same document to be inserted into the database multiple times.