diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx
index 51146e077..339de5f27 100644
--- a/src/AIModel/AIBase.cxx
+++ b/src/AIModel/AIBase.cxx
@@ -235,7 +235,9 @@ FGAIBase::removeModel()
     }
     else
     {
-        SG_LOG(SG_AI, SG_ALERT, "AIBase: Could not unload model. Missing scenery manager!");
+        aip.clear();
+        _model = 0;
+        _modeldata = 0;
     }
 }
 
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index dbce5df72..0ac6cfb28 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -229,6 +229,8 @@ FGJSBsim::FGJSBsim( double dt )
     fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias( node );
 // end of sim-time-sec deprecation patch
 
+    terrain = fgGetNode("/sim/fdm/surface", true);
+
     fdmex->Setdt( dt );
 
     result = fdmex->LoadModel( aircraft_path.str(),
@@ -1352,8 +1354,6 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off,
   SGQuatd hlToEc = SGQuatd::fromLonLat(geodPt);
   *agl = dot(hlToEc.rotate(SGVec3d(0, 0, 1)), SGVec3d(contact) - SGVec3d(pt));
 
-  static SGPropertyNode_ptr terrain = fgGetNode("/sim/fdm/surface", true);
-
 #ifdef JSBSIM_USE_GROUNDREACTIONS
   bool terrain_active = (terrain->getIntValue("override-level", -1) > 0) ? false : true;
   terrain->setBoolValue("active", terrain_active);
diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx
index accce2386..d6c3c6ab9 100644
--- a/src/FDM/JSBSim/JSBSim.hxx
+++ b/src/FDM/JSBSim/JSBSim.hxx
@@ -288,6 +288,8 @@ private:
 
     SGPropertyNode_ptr slaved;
 
+    SGPropertyNode_ptr terrain;
+
     static std::map<std::string,int> TURBULENCE_TYPE_NAMES;
 
     double last_hook_tip[3];