CGE2: Fix CppCheck warnings by reducing variable scope