Token processing environment check refactored to avoid optimizer's bailouts