Fixes issue with thread-safety on with-db