Fix error when searching in threaded mode