Fixed compile bug with THREADSAFE option