fixed race condition causing incorrect IDs to be reported on INSERT