Make thr->inside atomic && various fixes