fix a multithread bug revealed by owlapitools tests