Fixed mismatch alloc/dealloc, thread id checking routine

No match.