Fix bug where scopes werent pop during foreach gen