Fix thread ctors & dtors and atomic_cmpxchg retval