Removed possible race condition when generating new DocIDs.