Remove NIE from SetWaitNotificationRequired. Fixes #13742
Add block scope for foreach variables with statement only