Feature/thread safe r2

updated patch for the dbwrapper