diff --git a/docs-mini/Nasal.html b/docs-mini/Nasal.html index a7a21d0cc..622c6f644 100644 --- a/docs-mini/Nasal.html +++ b/docs-mini/Nasal.html @@ -394,7 +394,7 @@ which you can pass arbitrary Nasal source code for immediate execution:
-FGNasalSys n = (FGNasalSys*)globals->get_subsystem("nasal");
+auto n = globals->get_subsystem();
 if(! n->parseAndRun("print('This script was called from C++!')")) 
   SG_LOG(SG_GENERAL, SG_ALERT, "My Nasal code failed :(");
 
@@ -408,7 +408,7 @@ avoids the parsing and code generation overhead for the successive calls.
-FGNasalSys n = (FGNasalSys*)globals->get_subsystem("nasal");
+auto n = globals->get_subsystem();
 FGNasalScript* script = n->parseScript("print('Spam!')")) 
 if(!script) SG_LOG(SG_GENERAL, SG_ALERT, "My Nasal code failed :(");
 
diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx
index 932aa0acc..ed02e937c 100644
--- a/src/AIModel/AIAircraft.cxx
+++ b/src/AIModel/AIAircraft.cxx
@@ -94,7 +94,8 @@ FGAIAircraft::FGAIAircraft(FGAISchedule* ref) : /* HOT must be disabled for AI A
     prevSpeed = 0.0;
     prev_dist_to_go = 0.0;
 
-    PerformanceDB* perfDB = globals->get_subsystem();
+    auto perfDB = globals->get_subsystem();
+
     if (perfDB) {
         _performance = perfDB->getDefaultPerformance();
     } else {
@@ -184,7 +185,7 @@ void FGAIAircraft::unbind()
 
 void FGAIAircraft::setPerformance(const std::string& acType, const std::string& acclass)
 {
-    PerformanceDB* perfDB = globals->get_subsystem();
+    auto perfDB = globals->get_subsystem();
     if (perfDB) {
         _performance = perfDB->getDataFor(acType, acclass);
     }
diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx
index 8167b8846..2a5abf4d4 100644
--- a/src/AIModel/AICarrier.cxx
+++ b/src/AIModel/AICarrier.cxx
@@ -801,7 +801,7 @@ std::pair FGAICarrier::initialPositionForCarrier(const std::string
 
 SGSharedPtr FGAICarrier::findCarrierByNameOrPennant(const std::string& namePennant)
 {
-    const FGAIManager* aiManager = globals->get_subsystem();
+    const auto aiManager = globals->get_subsystem();
     if (!aiManager) {
         return {};
     }
diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx
index 9bb14c7cb..8d863cc8d 100644
--- a/src/AIModel/AIManager.cxx
+++ b/src/AIModel/AIManager.cxx
@@ -74,7 +74,7 @@ public:
         _unloadScript = nasalScripts->getStringValue("unload");
         std::string loadScript = nasalScripts->getStringValue("load");
         if (!loadScript.empty()) {
-            FGNasalSys* nasalSys = globals->get_subsystem();
+            auto nasalSys = globals->get_subsystem();
             std::string moduleName = "scenario_" + _internalName;
             bool ok = nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
                                              loadScript.c_str(), loadScript.size(),
@@ -94,7 +94,7 @@ public:
                       [](FGAIBasePtr ai) { ai->setDie(true); });
 
 
-        FGNasalSys* nasalSys = globals->get_subsystem();
+        auto nasalSys = globals->get_subsystem();
         if (!nasalSys) // happens during shutdown / reset
             return;
 
diff --git a/src/ATC/GroundController.cxx b/src/ATC/GroundController.cxx
index 5b77efbac..ac16bb5b8 100644
--- a/src/ATC/GroundController.cxx
+++ b/src/ATC/GroundController.cxx
@@ -156,7 +156,7 @@ bool FGGroundController::checkTransmissionState(int minState, int maxState, Traf
                 trans_num->setIntValue(-1);
                 // PopupCallback(n);
                 SG_LOG(SG_ATC, SG_DEBUG, "Selected transmission message " << n);
-                //FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
+                //auto atc = globals->get_subsystem();
                 //FGATCDialogNew::instance()->removeEntry(1);
             } else {
                 SG_LOG(SG_ATC, SG_DEBUG, "creating message for " << i->getAircraft()->getCallSign());
diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx
index 208e7edd9..6cf532780 100644
--- a/src/ATC/atc_mgr.cxx
+++ b/src/ATC/atc_mgr.cxx
@@ -82,7 +82,7 @@ void FGATCManager::postinit()
     _routeManagerDestinationAirportNode = globals->get_props()->getNode("/autopilot/route-manager/destination/airport", true);
     destination = _routeManagerDestinationAirportNode->getStringValue();
 
-    FGAIManager* aiManager = globals->get_subsystem();
+    auto aiManager = globals->get_subsystem();
     auto userAircraft = aiManager->getUserAircraft();
     string callsign = userAircraft->getCallSign();
 
@@ -257,7 +257,7 @@ void FGATCManager::reposition()
 
 // remove any parking assignment form the user flight-plan, so it's
 // available again. postinit() will recompute a new value if required
-    FGAIManager* aiManager = globals->get_subsystem();
+    auto aiManager = globals->get_subsystem();
     auto userAircraft = aiManager->getUserAircraft();
     if (userAircraft) {
         if (userAircraft->GetFlightPlan()) {
@@ -303,7 +303,7 @@ void FGATCManager::update ( double time ) {
     // SG_LOG(SG_ATC, SG_BULK, "ATC update code is running at time: " << time);
 
     // Test code: let my virtual co-pilot handle ATC
-    FGAIManager* aiManager = globals->get_subsystem();
+    auto aiManager = globals->get_subsystem();
     FGAIAircraft* user_ai_ac = aiManager->getUserAircraft();
     FGAIFlightPlan *fp = user_ai_ac->GetFlightPlan();
 
diff --git a/src/Add-ons/Addon.cxx b/src/Add-ons/Addon.cxx
index 1458285e5..1685a83aa 100644
--- a/src/Add-ons/Addon.cxx
+++ b/src/Add-ons/Addon.cxx
@@ -290,7 +290,7 @@ void Addon::setAddonNode(SGPropertyNode* addonNode)
 
 naRef Addon::getAddonPropsNode() const
 {
-  FGNasalSys* nas = globals->get_subsystem();
+  auto nas = globals->get_subsystem();
   return nas->wrappedPropsNode(_addonNode.get());
 }
 
diff --git a/src/Airports/airport.cxx b/src/Airports/airport.cxx
index 14cf5862e..4b7401a39 100644
--- a/src/Airports/airport.cxx
+++ b/src/Airports/airport.cxx
@@ -407,7 +407,7 @@ void FGAirport::addLineFeature(FGPavementRef linefeature)
 FGRunwayRef FGAirport::getActiveRunwayForUsage() const
 {
   auto envMgr = globals->get_subsystem();
-
+  
   // This forces West-facing rwys to be used in no-wind situations
   // which is consistent with Flightgear's initial setup.
   double hdg = 270;
diff --git a/src/Airports/airportdynamicsmanager.cxx b/src/Airports/airportdynamicsmanager.cxx
index 2c58184f0..03a3bc52d 100644
--- a/src/Airports/airportdynamicsmanager.cxx
+++ b/src/Airports/airportdynamicsmanager.cxx
@@ -94,7 +94,7 @@ FGAirportDynamicsRef AirportDynamicsManager::find(const std::string &icao)
     if (icao.empty())
         return FGAirportDynamicsRef();
 
-    AirportDynamicsManager* instance = globals->get_subsystem();
+    auto instance = globals->get_subsystem();
     if (!instance)
         return FGAirportDynamicsRef();
 
diff --git a/src/Airports/dynamics.cxx b/src/Airports/dynamics.cxx
index 1c3ac104d..16cde7fba 100644
--- a/src/Airports/dynamics.cxx
+++ b/src/Airports/dynamics.cxx
@@ -189,7 +189,7 @@ private:
     void populate()
     {
         SGVec3d cartAirportPos = m_airport->cart();
-        FGAIManager* aiManager = globals->get_subsystem();
+        auto aiManager = globals->get_subsystem();
         for (auto ai : aiManager->get_ai_list()) {
             const auto cart = ai->getCartPos();
 
@@ -714,7 +714,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
         /*
         FGEnvironment
             stationweather =
-            ((FGEnvironmentMgr *) globals->get_subsystem("environment"))
+            globals->get_subsystem()
             ->getEnvironment(getLatitude(), getLongitude(),
                              getElevation());
         */
diff --git a/src/Autopilot/digitalfilter.cxx b/src/Autopilot/digitalfilter.cxx
index 47b93a9c9..a79e057da 100644
--- a/src/Autopilot/digitalfilter.cxx
+++ b/src/Autopilot/digitalfilter.cxx
@@ -925,7 +925,7 @@ bool DigitalFilter::configure( SGPropertyNode& prop_root,
   _implementation->collectDependentProperties(inputs);
   collectDependentProperties(inputs);
   
-  Highlight* highlight = globals->get_subsystem();
+  auto highlight = globals->get_subsystem();
   if (highlight) {
     for (auto in: inputs) {
       for (auto& out: _output_list) {
diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx
index 888d3fc59..3d9b5a02d 100644
--- a/src/Autopilot/route_mgr.cxx
+++ b/src/Autopilot/route_mgr.cxx
@@ -59,14 +59,14 @@ namespace su = simgear::strutils;
 
 static bool commandLoadFlightPlan(const SGPropertyNode* arg, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   SGPath path = SGPath::fromUtf8(arg->getStringValue("path"));
   return self->loadRoute(path);
 }
 
 static bool commandSaveFlightPlan(const SGPropertyNode* arg, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   SGPath path = SGPath::fromUtf8(arg->getStringValue("path"));
   const SGPath authorizedPath = SGPath(path).validate(true /* write */);
 
@@ -88,7 +88,7 @@ static bool commandSaveFlightPlan(const SGPropertyNode* arg, SGPropertyNode *)
 
 static bool commandActivateFlightPlan(const SGPropertyNode* arg, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   bool activate = arg->getBoolValue("activate", true);
   if (activate) {
     self->activate();
@@ -101,14 +101,14 @@ static bool commandActivateFlightPlan(const SGPropertyNode* arg, SGPropertyNode
 
 static bool commandClearFlightPlan(const SGPropertyNode*, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   self->clearRoute();
   return true;
 }
 
 static bool commandSetActiveWaypt(const SGPropertyNode* arg, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   int index = arg->getIntValue("index");
   if ((index < 0) || (index >= self->numLegs())) {
     return false;
@@ -120,7 +120,7 @@ static bool commandSetActiveWaypt(const SGPropertyNode* arg, SGPropertyNode *)
 
 static bool commandInsertWaypt(const SGPropertyNode* arg, SGPropertyNode *)
 {
-    FGRouteMgr* self = globals->get_subsystem();
+    auto self = globals->get_subsystem();
     const bool haveIndex = arg->hasChild("index");
     int index = arg->getIntValue("index");
 
@@ -234,7 +234,7 @@ static bool commandInsertWaypt(const SGPropertyNode* arg, SGPropertyNode *)
 
 static bool commandDeleteWaypt(const SGPropertyNode* arg, SGPropertyNode *)
 {
-  FGRouteMgr* self = (FGRouteMgr*) globals->get_subsystem("route-manager");
+  auto self = globals->get_subsystem();
   int index = arg->getIntValue("index");
   self->removeLegAtIndex(index);
   return true;
@@ -673,7 +673,7 @@ void FGRouteMgr::update_mirror()
 {
     _routePath.reset(); // wipe this so we re-compute on next update()
   mirror->removeChildren("wp");
-  NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+  auto gui = globals->get_subsystem();
   FGDialog* rmDlg = gui ? gui->getDialog("route-manager") : NULL;
 
   if (!_plan) {
diff --git a/src/Canvas/FGCanvasSystemAdapter.cxx b/src/Canvas/FGCanvasSystemAdapter.cxx
index 67f9afef8..84dc6823d 100644
--- a/src/Canvas/FGCanvasSystemAdapter.cxx
+++ b/src/Canvas/FGCanvasSystemAdapter.cxx
@@ -109,13 +109,13 @@ namespace canvas
   SGSubsystem*
   FGCanvasSystemAdapter::getSubsystem(const std::string& name) const
   {
-    return globals->get_subsystem(name.c_str());
+    return globals->get_subsystem_mgr()->get_subsystem(name.c_str());
   }
 
   //----------------------------------------------------------------------------
   simgear::HTTP::Client* FGCanvasSystemAdapter::getHTTPClient() const
   {
-    FGHTTPClient* http = globals->get_subsystem();
+    auto http = globals->get_subsystem();
 
     if( http )
       return http->client();
diff --git a/src/Cockpit/NavDisplay.cxx b/src/Cockpit/NavDisplay.cxx
index 2c81b024e..88555cc29 100644
--- a/src/Cockpit/NavDisplay.cxx
+++ b/src/Cockpit/NavDisplay.cxx
@@ -514,7 +514,7 @@ NavDisplay::init ()
     _odg = new FGODGauge;
     _odg->setSize(_Instrument->getIntValue("texture-size", 512));
 
-    _route = static_cast(globals->get_subsystem("route-manager"));
+    _route = globals->get_subsystem();
     
     _navRadio1Node = fgGetNode("/instrumentation/nav[0]", true);
     _navRadio2Node = fgGetNode("/instrumentation/nav[1]", true);
diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx
index 475e3b699..072c0ddbf 100644
--- a/src/Cockpit/panel.cxx
+++ b/src/Cockpit/panel.cxx
@@ -289,7 +289,7 @@ FGPanel::draw(osg::State& state)
   state.setActiveTextureUnit(0);
   state.setClientActiveTextureUnit(0);
 
-  FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
+  auto l = globals->get_subsystem();
   sgCopyVec4( panel_color, l->scene_diffuse().data());
   if ( fgGetDouble("/systems/electrical/outputs/instrument-lights") > 1.0 ) {
       if ( panel_color[0] < 0.7 ) panel_color[0] = 0.7;
diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx
index be26c75a7..77a41a1c9 100644
--- a/src/Cockpit/panel_io.cxx
+++ b/src/Cockpit/panel_io.cxx
@@ -779,7 +779,7 @@ readPanel (const SGPropertyNode * root, const SGPath& path)
           
           // Warning - hardwired size!!!
           RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
-          KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+          auto gps = globals->get_subsystem();
 		  if (gps == NULL) {
 			  gps = new KLN89(instrument);
 			  globals->get_subsystem_mgr()->add("kln89", gps);
diff --git a/src/Environment/climate.cxx b/src/Environment/climate.cxx
index 79603fd37..7d252e3d9 100644
--- a/src/Environment/climate.cxx
+++ b/src/Environment/climate.cxx
@@ -145,7 +145,7 @@ void FGClimate::reinit()
 // http://vectormap.si.edu/Climate.htm
 void FGClimate::update(double dt)
 {
-    FGLight *l = globals->get_subsystem();
+    auto l = globals->get_subsystem();
     if (l)
     {
         _sun_longitude_deg = l->get_sun_lon()*SGD_RADIANS_TO_DEGREES;
diff --git a/src/Environment/realwx_ctrl.cxx b/src/Environment/realwx_ctrl.cxx
index a1acc1fe2..8f2ec8fba 100644
--- a/src/Environment/realwx_ctrl.cxx
+++ b/src/Environment/realwx_ctrl.cxx
@@ -203,7 +203,7 @@ protected:
 
 static bool commandRequestMetar(const SGPropertyNode * arg, SGPropertyNode * root)
 {
-  SGSubsystemGroup* envMgr = (SGSubsystemGroup*) globals->get_subsystem("environment");
+  auto envMgr = (SGSubsystemGroup*) globals->get_subsystem_mgr()->get_subsystem("environment");
   if (!envMgr) {
     return false;
   }
@@ -223,7 +223,7 @@ static bool commandRequestMetar(const SGPropertyNode * arg, SGPropertyNode * roo
   
 static bool commandClearMetar(const SGPropertyNode * arg, SGPropertyNode * root)
 {
-  SGSubsystemGroup* envMgr = (SGSubsystemGroup*) globals->get_subsystem("environment");
+  auto envMgr = (SGSubsystemGroup*) globals->get_subsystem_mgr()->get_subsystem("environment");
   if (!envMgr) {
     return false;
   }
@@ -500,7 +500,7 @@ void NoaaMetarRealWxController::requestMetar
     "NoaaMetarRealWxController::update(): "
     "spawning load request for station-id '" << upperId << "'"
   );
-  FGHTTPClient* http = globals->get_subsystem();
+  auto http = globals->get_subsystem();
   if (http) {
       http->makeRequest(new NoaaMetarGetRequest(metarDataHandler, upperId, noaa_base_url));
   }
diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx
index ff3335f50..5455ada42 100644
--- a/src/GUI/CanvasWidget.cxx
+++ b/src/GUI/CanvasWidget.cxx
@@ -69,7 +69,7 @@ CanvasWidget::CanvasWidget( int x, int y,
   if( !nasal )
     return;
 
-  FGNasalSys *nas = globals->get_subsystem();
+  auto nas = globals->get_subsystem();
   if( !nas )
     SG_LOG( SG_GENERAL,
             SG_ALERT,
diff --git a/src/GUI/CatalogListModel.cxx b/src/GUI/CatalogListModel.cxx
index 1161c13b3..ec74e01af 100644
--- a/src/GUI/CatalogListModel.cxx
+++ b/src/GUI/CatalogListModel.cxx
@@ -201,7 +201,7 @@ void CatalogListModel::refreshCatalog(int index)
 
 void CatalogListModel::installDefaultCatalog(bool showAddFeedback)
 {
-    FGHTTPClient* http = globals->get_subsystem();
+    auto http = globals->get_subsystem();
     CatalogRef cat = Catalog::createFromUrl(m_packageRoot, http->getDefaultCatalogUrl());
     if (showAddFeedback) {
       m_newlyAddedCatalog = cat;
@@ -290,7 +290,7 @@ void CatalogListModel::onCatalogStatusChanged(Catalog* cat)
     // compute the version-specific URL. This is the logic which bounces the UI
     // to the fallback URL.
     if (cat->status() == Delegate::FAIL_NOT_FOUND) {
-        FGHTTPClient* http = globals->get_subsystem();
+        auto http = globals->get_subsystem();
         if (cat->url() == http->getDefaultCatalogUrl()) {
             cat->setUrl(http->getDefaultCatalogFallbackUrl());
             cat->refresh(); // and trigger another refresh
diff --git a/src/GUI/FGPUICompatDialog.cxx b/src/GUI/FGPUICompatDialog.cxx
index ba45775ee..8d0f1a72a 100644
--- a/src/GUI/FGPUICompatDialog.cxx
+++ b/src/GUI/FGPUICompatDialog.cxx
@@ -476,7 +476,7 @@ FGPUIDialog::makeObject(SGPropertyNode* props, int parentWidth, int parentHeight
                 obj->setBuffer(tsync->log());
             }
         } else {
-            FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
+            auto nasal = globals->get_subsystem();
             obj->setBuffer(nasal->log());
         }
 
diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx
index 548b56b7d..f52969cdf 100644
--- a/src/GUI/FGPUIDialog.cxx
+++ b/src/GUI/FGPUIDialog.cxx
@@ -576,7 +576,7 @@ static void
 action_callback(puObject* object)
 {
     GUIInfo* info = (GUIInfo*)object->getUserData();
-    NewGUI* gui = (NewGUI*)globals->get_subsystem("gui");
+    auto gui = globals->get_subsystem();
     gui->setActiveDialog(info->dialog);
     int nBindings = info->bindings.size();
     for (int i = 0; i < nBindings; i++) {
@@ -1087,7 +1087,7 @@ FGPUIDialog::makeObject(SGPropertyNode* props, int parentWidth, int parentHeight
                 obj->setBuffer(tsync->log());
             }
         } else {
-            FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
+            auto nasal = globals->get_subsystem();
             obj->setBuffer(nasal->log());
         }
 
diff --git a/src/GUI/FGPUIMenuBar.cxx b/src/GUI/FGPUIMenuBar.cxx
index 9a43119a4..05fddedc9 100755
--- a/src/GUI/FGPUIMenuBar.cxx
+++ b/src/GUI/FGPUIMenuBar.cxx
@@ -73,7 +73,7 @@ add_deprecated_dialogs ()
 static void
 menu_callback (puObject * object)
 {
-    NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+    auto gui = globals->get_subsystem();
     FGPUIMenuBar* mb = static_cast(gui->getMenuBar());
     mb->fireItem(object);
 }
@@ -381,7 +381,7 @@ namespace {
   
   struct EnabledListener : SGPropertyChangeListener {
     void valueChanged(SGPropertyNode *node) {
-        NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+        auto gui = globals->get_subsystem();
         if (!gui)
             return;
         FGPUIMenuBar* menubar = static_cast(gui->getMenuBar());
diff --git a/src/GUI/FileDialog.cxx b/src/GUI/FileDialog.cxx
index 12f36ac95..f45dbeb52 100644
--- a/src/GUI/FileDialog.cxx
+++ b/src/GUI/FileDialog.cxx
@@ -92,15 +92,15 @@ public:
         func(f),
         object(obj)
     {
-        FGNasalSys* sys = globals->get_subsystem();
+        auto sys = globals->get_subsystem();
         _gcKeys[0] = sys->gcSave(f);
         _gcKeys[1] = sys->gcSave(obj);
     }
     
     void onFileDialogDone(FGFileDialog* instance, const SGPath& aPath) override
     {
-        FGNasalSys* sys = globals->get_subsystem();
-
+        auto sys = globals->get_subsystem();
+        
         naContext ctx = naNewContext();
         naRef args[1];
         args[0] = nasal::to_nasal(ctx, aPath);
@@ -111,7 +111,7 @@ public:
     
     ~NasalCallback()
     {
-        FGNasalSys* sys = globals->get_subsystem();
+        auto sys = globals->get_subsystem();
         if (!sys) // happens during Nasal shutdown on reset
             return;
         
diff --git a/src/GUI/Highlight.cxx b/src/GUI/Highlight.cxx
index fac356184..f8f56994c 100644
--- a/src/GUI/Highlight.cxx
+++ b/src/GUI/Highlight.cxx
@@ -328,10 +328,10 @@ struct FdmInitialisedListener : SGPropertyChangeListener
         if (m_fdm_initialised->getBoolValue())
         {
             SG_LOG(SG_GENERAL, SG_DEBUG, "Getting property associations from FDM");
-            Highlight* highlight = globals->get_subsystem();
+            auto highlight = globals->get_subsystem();
             if (highlight)
             {
-                FDMShell* fdmshell = (FDMShell*) globals->get_subsystem("flight");
+                auto fdmshell = globals->get_subsystem();
                 FGInterface* fginterface = fdmshell->getInterface();
                 assert(fginterface);
                 fginterface->property_associations(
diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx
index 04f274c9a..0472950e2 100644
--- a/src/GUI/MapWidget.cxx
+++ b/src/GUI/MapWidget.cxx
@@ -464,7 +464,7 @@ const int SHOW_DETAIL2_ZOOM = 5;
 MapWidget::MapWidget(int x, int y, int maxX, int maxY) :
   puObject(x,y,maxX, maxY)
 {
-  _route = static_cast(globals->get_subsystem("route-manager"));
+  _route = globals->get_subsystem();
   _gps = fgGetNode("/instrumentation/gps");
 
   _width = maxX - x;
@@ -687,7 +687,7 @@ void MapWidget::update()
     // symbols.
     _drawRangeNm = SGGeodesy::distanceNm(_projectionCenter, topLeft) + 10.0;
   
-    FGFlightHistory* history = (FGFlightHistory*) globals->get_subsystem("history");
+    auto history = globals->get_subsystem();
     if (history && _root->getBoolValue("draw-flight-history")) {
         _flightHistoryPath = history->pathForHistory();
     } else {
@@ -2038,7 +2038,7 @@ MapWidget::DrawAIObject::DrawAIObject(SGPropertyNode* m, const SGGeod& g) :
         // try to access the flight-plan of the aircraft. There are several layers
         // of potential NULL-ness here, so we have to be defensive at each stage.
         std::string originICAO, destinationICAO;
-        FGAIManager* aiManager = globals->get_subsystem();
+        auto aiManager = globals->get_subsystem();
         FGAIBasePtr aircraft = aiManager ? aiManager->getObjectFromProperty(model) : NULL;
         if (aircraft) {
             FGAIAircraft* p = static_cast(aircraft.get());
diff --git a/src/GUI/MessageBox.cxx b/src/GUI/MessageBox.cxx
index e08b4b284..97fcfc0ff 100644
--- a/src/GUI/MessageBox.cxx
+++ b/src/GUI/MessageBox.cxx
@@ -158,7 +158,7 @@ MessageBoxResult modalMessageBox(const std::string& caption,
         s += "\n( " +  moreText + ")";
     }
 
-    NewGUI* gui = globals->get_subsystem();
+    auto gui = globals->get_subsystem();
     if (!gui || (fgGetBool("/sim/rendering/initialized", false) == false)) {
         SG_LOG(SG_GENERAL, SG_POPUP, s);
     } else {
@@ -202,7 +202,7 @@ MessageBoxResult fatalMessageBoxWithoutExit(const std::string& caption,
     if (fgGetBool("/sim/rendering/initialized", false) == false) {
         std::cerr << s << std::endl;
     } else {
-        NewGUI* _gui = (NewGUI *)globals->get_subsystem("gui");
+        auto _gui = globals->get_subsystem();
         SGPropertyNode_ptr dlg = _gui->getDialogProperties("popup");
         dlg->setStringValue("text/label", s  );
         _gui->showDialog("popup");
diff --git a/src/GUI/PUICompatObject.cxx b/src/GUI/PUICompatObject.cxx
index 8349efc49..90a199f74 100644
--- a/src/GUI/PUICompatObject.cxx
+++ b/src/GUI/PUICompatObject.cxx
@@ -222,7 +222,7 @@ naRef PUICompatObject::property() const
     if (!_value)
         return naNil();
     
-    FGNasalSys* nas = globals->get_subsystem();
+    auto nas = globals->get_subsystem();
     return nas->wrappedPropsNode(_value.get());
 }
 
@@ -234,7 +234,7 @@ naRef PUICompatObject::propertyValue(naContext ctx) const
 
 naRef PUICompatObject::config() const
 {
-    FGNasalSys* nas = globals->get_subsystem();
+    auto nas = globals->get_subsystem();
     return nas->wrappedPropsNode(_config.get());
 }
 
diff --git a/src/GUI/PUIFileDialog.cxx b/src/GUI/PUIFileDialog.cxx
index 92c6331cd..0f865f71e 100644
--- a/src/GUI/PUIFileDialog.cxx
+++ b/src/GUI/PUIFileDialog.cxx
@@ -43,7 +43,7 @@ PUIFileDialog::~PUIFileDialog()
 
 void PUIFileDialog::exec()
 {
-    NewGUI* gui = static_cast(globals->get_subsystem("gui"));
+    auto gui = globals->get_subsystem();
     std::string name("native-file-0");
     _dialogRoot = fgGetNode("/sim/gui/dialogs/" + name, true);
 
@@ -80,7 +80,7 @@ void PUIFileDialog::exec()
 
 void PUIFileDialog::close()
 {
-    NewGUI* gui = static_cast(globals->get_subsystem("gui"));
+    auto gui = globals->get_subsystem();
     std::string name("native-file-0");
     gui->closeDialog(name);
 }
diff --git a/src/GUI/QtQuickFGCanvasItem.cxx b/src/GUI/QtQuickFGCanvasItem.cxx
index c6a40ea49..615155f4e 100644
--- a/src/GUI/QtQuickFGCanvasItem.cxx
+++ b/src/GUI/QtQuickFGCanvasItem.cxx
@@ -212,7 +212,7 @@ void QtQuickFGCanvasItem::setCanvas(QString canvas)
     _canvasName = canvas;
 
     if (!_canvasName.isEmpty()) {
-        CanvasMgr* canvasManager = globals->get_subsystem();
+        auto canvasManager = globals->get_subsystem();
         _canvas = canvasManager->createCanvas("");
 
         SGPropertyNode* cprops = _canvas->getProps();
@@ -232,7 +232,7 @@ void QtQuickFGCanvasItem::initCanvasNasalModules()
     if( !nasal )
       return;
 
-    FGNasalSys *nas = globals->get_subsystem();
+    auto nas = globals->get_subsystem();
     if( !nas )
       SG_LOG( SG_GENERAL,
               SG_ALERT,
diff --git a/src/GUI/WaypointList.cxx b/src/GUI/WaypointList.cxx
index 3804f064e..2e3160bab 100644
--- a/src/GUI/WaypointList.cxx
+++ b/src/GUI/WaypointList.cxx
@@ -124,7 +124,7 @@ public:
     
     if (prop->getNameString() == "flightplan-changed") {
       _fp = 
-        static_cast(globals->get_subsystem("route-manager"))->flightPlan();
+        globals->get_subsystem()->flightPlan();
     }
   }
 private:
@@ -169,7 +169,7 @@ WaypointList::WaypointList(int x, int y, int width, int height) :
   // pretend to be a list, so fgPopup doesn't mess with our mouse events
   type |= PUCLASS_LIST;  
   flightgear::FlightPlan* fp = 
-    static_cast(globals->get_subsystem("route-manager"))->flightPlan();
+    globals->get_subsystem()->flightPlan();
   setModel(new FlightPlanWaypointModel(fp));
   setSize(width, height);
   setValue(-1);
diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx
index edf117c35..5e687e09f 100644
--- a/src/GUI/gui_funcs.cxx
+++ b/src/GUI/gui_funcs.cxx
@@ -101,7 +101,7 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
 // and we don't want to miss any, either.)
 void mkDialog (const char *txt)
 {
-    NewGUI *gui = (NewGUI *)globals->get_subsystem("gui");
+    auto gui = globals->get_subsystem();
     if (!gui)
         return;
     SGPropertyNode *master = gui->getDialogProperties("message");
diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx
index f0985f92b..f1015a2aa 100644
--- a/src/GUI/new_gui.cxx
+++ b/src/GUI/new_gui.cxx
@@ -95,7 +95,7 @@ static void scanMenus()
     sim/menubar/default/menu[]/item[]. */
     SGPropertyNode* menubar = globals->get_props()->getNode("sim/menubar/default");
     assert(menubar);
-    Highlight* highlight = globals->get_subsystem();
+    auto highlight = globals->get_subsystem();
     if (!highlight) {
         return;
     }
@@ -469,7 +469,7 @@ NewGUI::readDir (const SGPath& path)
 
     flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
     flightgear::NavDataCache::Transaction txn(cache);
-    Highlight* highlight = globals->get_subsystem();
+    auto highlight = globals->get_subsystem();
     for (SGPath xmlPath : dir.children(simgear::Dir::TYPE_FILE, ".xml")) {
 
       SGPropertyNode_ptr props = new SGPropertyNode;
diff --git a/src/Input/FGEventInput.cxx b/src/Input/FGEventInput.cxx
index 8993c0388..831804103 100644
--- a/src/Input/FGEventInput.cxx
+++ b/src/Input/FGEventInput.cxx
@@ -253,7 +253,7 @@ void FGButtonEvent::update( double dt )
 
 FGInputDevice::~FGInputDevice()
 {
-  FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+  auto nas = globals->get_subsystem();
   if (nas && deviceNode ) {
     SGPropertyNode_ptr nasal = deviceNode->getNode("nasal");
     if( nasal ) {
@@ -297,7 +297,7 @@ void FGInputDevice::Configure( SGPropertyNode_ptr aDeviceNode )
     SGPropertyNode_ptr open = nasal->getNode("open");
     if (open) {
       const string s = open->getStringValue();
-      FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
+      auto nas = globals->get_subsystem();
       if (nas)
         nas->createModule(nasalModule.c_str(), nasalModule.c_str(), s.c_str(), s.length(), deviceNode );
     }
@@ -535,7 +535,7 @@ bool FGReportSetting::Test()
 
 std::string FGReportSetting::reportBytes(const std::string& moduleName) const
 {
-    FGNasalSys *nas = globals->get_subsystem();
+    auto nas = globals->get_subsystem();
     if (!nas) {
         return {};
     }
diff --git a/src/Input/FGJoystickInput.cxx b/src/Input/FGJoystickInput.cxx
index 2524dbaa3..ff97a7ea5 100644
--- a/src/Input/FGJoystickInput.cxx
+++ b/src/Input/FGJoystickInput.cxx
@@ -195,7 +195,7 @@ void FGJoystickInput::reinit()
 
 void FGJoystickInput::postinit()
 {
-  FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
+  auto nasalsys = globals->get_subsystem();
   SGPropertyNode_ptr js_nodes = fgGetNode("/input/joysticks");
 
   for (int i = 0; i < MAX_JOYSTICKS; i++) {
diff --git a/src/Input/FGKeyboardInput.cxx b/src/Input/FGKeyboardInput.cxx
index 3bee96c17..1749901f7 100644
--- a/src/Input/FGKeyboardInput.cxx
+++ b/src/Input/FGKeyboardInput.cxx
@@ -107,7 +107,7 @@ void FGKeyboardInput::postinit()
     key_nodes = fgGetNode("/input/keyboard", true);
   }
 
-  FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
+  auto nasalsys = globals->get_subsystem();
   PropertyList nasal = key_nodes->getChildren("nasal");
   for (unsigned int j = 0; j < nasal.size(); j++) {
     nasal[j]->setStringValue("module", module.c_str());
diff --git a/src/Instrumentation/KLN89/kln89.cxx b/src/Instrumentation/KLN89/kln89.cxx
index e2b0f0517..9da285b6c 100644
--- a/src/Instrumentation/KLN89/kln89.cxx
+++ b/src/Instrumentation/KLN89/kln89.cxx
@@ -57,75 +57,75 @@ using std::string;
 
 static bool do_kln89_msg_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
 	//cout << "do_kln89_msg_pressed called!\n";
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->MsgPressed();
 	return(true);
 }
 
 static bool do_kln89_obs_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
 	//cout << "do_kln89_obs_pressed called!\n";
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->OBSPressed();
 	return(true);
 }
 
 static bool do_kln89_alt_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
 	//cout << "do_kln89_alt_pressed called!\n";
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->AltPressed();
 	return(true);
 }
 
 static bool do_kln89_nrst_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->NrstPressed();
 	return(true);
 }
 
 static bool do_kln89_dto_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->DtoPressed();
 	return(true);
 }
 
 static bool do_kln89_clr_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->ClrPressed();
 	return(true);
 }
 
 static bool do_kln89_ent_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->EntPressed();
 	return(true);
 }
 
 static bool do_kln89_crsr_pressed(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->CrsrPressed();
 	return(true);
 }
 
 static bool do_kln89_knob1left1(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->Knob1Left1();
 	return(true);
 }
 
 static bool do_kln89_knob1right1(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->Knob1Right1();
 	return(true);
 }
 
 static bool do_kln89_knob2left1(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->Knob2Left1();
 	return(true);
 }
 
 static bool do_kln89_knob2right1(const SGPropertyNode * arg, SGPropertyNode * root) {
-	KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
+	auto gps = globals->get_subsystem();
 	gps->Knob2Right1();
 	return(true);
 }
diff --git a/src/Instrumentation/adf.cxx b/src/Instrumentation/adf.cxx
index 73dab674c..de396118b 100644
--- a/src/Instrumentation/adf.cxx
+++ b/src/Instrumentation/adf.cxx
@@ -105,7 +105,7 @@ ADF::init ()
     _heading_node       = fgGetNode("/orientation/heading-deg", true);
 
     // sound support (audible ident code)
-    SGSoundMgr *smgr = globals->get_subsystem();
+    auto smgr = globals->get_subsystem();
     _sgr = smgr->find("avionics", true);
     _sgr->tie_to_listener();
 
diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx
index 7a8211881..e2a59a22c 100644
--- a/src/Instrumentation/airspeed_indicator.cxx
+++ b/src/Instrumentation/airspeed_indicator.cxx
@@ -81,7 +81,7 @@ AirspeedIndicator::init ()
         _pressure_alt = fgGetNode(_pressure_alt_source.c_str(), true);
     }
     
-    _environmentManager = (FGEnvironmentMgr*) globals->get_subsystem("environment");
+    _environmentManager = globals->get_subsystem();
 }
 
 void
diff --git a/src/Instrumentation/commradio.cxx b/src/Instrumentation/commradio.cxx
index 2d975b1ef..0713f46ab 100644
--- a/src/Instrumentation/commradio.cxx
+++ b/src/Instrumentation/commradio.cxx
@@ -133,7 +133,7 @@ void AtisSpeaker::valueChanged(SGPropertyNode * node)
     }
   }
 
-  FGSoundManager * smgr = globals->get_subsystem();
+  auto smgr = globals->get_subsystem();
   if (!smgr) {
       return;
   }
diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx
index 0de9b051c..c3cb3e899 100644
--- a/src/Instrumentation/gps.cxx
+++ b/src/Instrumentation/gps.cxx
@@ -358,7 +358,7 @@ GPS::update (double delta_time_sec)
   if (_dataValid && (_mode == "init")) {
     // will select LEG mode if the route is active
     routeManagerFlightPlanChanged(nullptr);
-    FGRouteMgr* routeMgr = globals->get_subsystem();
+    auto routeMgr = globals->get_subsystem();
       
     if (!routeMgr || !routeMgr->isRouteActive()) {
       // initialise in OBS mode, with waypt set to the nearest airport.
@@ -397,7 +397,7 @@ void GPS::routeManagerFlightPlanChanged(SGPropertyNode*)
   }
   
   SG_LOG(SG_INSTR, SG_DEBUG, "GPS saw route-manager flight-plan replaced.");
-  FGRouteMgr* routeMgr = globals->get_subsystem();
+  auto routeMgr = globals->get_subsystem();
   if (!routeMgr) {
     return;
   }
diff --git a/src/Instrumentation/kr_87.cxx b/src/Instrumentation/kr_87.cxx
index f7774bf92..191b2c7b0 100644
--- a/src/Instrumentation/kr_87.cxx
+++ b/src/Instrumentation/kr_87.cxx
@@ -114,7 +114,7 @@ FGKR_87::~FGKR_87() {
 
 
 void FGKR_87::init () {
-    SGSoundMgr *smgr = globals->get_subsystem();
+    auto smgr = globals->get_subsystem();
     _sgr = smgr->find("avionics", true);
     _sgr->tie_to_listener();
 }
diff --git a/src/Instrumentation/marker_beacon.cxx b/src/Instrumentation/marker_beacon.cxx
index 902ae20ad..6bb2fc80a 100644
--- a/src/Instrumentation/marker_beacon.cxx
+++ b/src/Instrumentation/marker_beacon.cxx
@@ -103,7 +103,7 @@ FGMarkerBeacon::init ()
     if (audio_btn->getType() == simgear::props::NONE)
         audio_btn->setBoolValue( true );
 
-    SGSoundMgr *smgr = globals->get_subsystem();
+    auto smgr = globals->get_subsystem();
     if (smgr) {
         _audioSampleGroup = smgr->find("avionics", true);
         _audioSampleGroup->tie_to_listener();
diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
index 5f7925ae2..66f88f601 100644
--- a/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
@@ -211,7 +211,7 @@ do_nasal (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_replay (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
+    auto r = globals->get_subsystem();
     return r->start();
 }
 
@@ -317,7 +317,7 @@ do_save (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_save_tape (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
+    auto replay = globals->get_subsystem();
     replay->saveTape(arg);
 
     return true;
@@ -329,7 +329,7 @@ do_save_tape (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_load_tape (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
+    auto replay = globals->get_subsystem();
     replay->loadTape(arg);
 
     return true;
@@ -807,7 +807,7 @@ do_property_interpolate (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_data_logging_commit (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    FGLogger *log = (FGLogger *)globals->get_subsystem("logger");
+    auto log = globals->get_subsystem();
     log->reinit();
     return true;
 }
@@ -913,7 +913,7 @@ do_load_xml_to_proptree(const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_load_xml_from_url(const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    FGHTTPClient* http = static_cast(globals->get_subsystem("http"));
+    auto http = globals->get_subsystem();
     if (!http) {
         SG_LOG(SG_IO, SG_ALERT, "xmlhttprequest: HTTP client not running");
         return false;
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index 94731fde9..48e68b3c5 100755
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -94,7 +94,7 @@
 
 #include 
 #include 
-
+ 
 #include 
 #include 
 #include 
@@ -1014,7 +1014,7 @@ void fgCreateSubsystems(bool duringReset) {
         }
 
         // may exist already due to GUI startup or --load-tape=http...
-        if (!globals->get_subsystem()) {
+        if (!mgr->get_subsystem()) {
             mgr->add();
         }
         mgr->add();
@@ -1079,7 +1079,7 @@ void fgCreateSubsystems(bool duringReset) {
         // properties before it is initialised. This caused problems when
         // FGReplay was changed to be POST_FDM.
         mgr->add();
-        mgr->get_subsystem("replay")->init(); // Special case.
+        mgr->get_subsystem()->init(); // Special case.
 
         //mgr->add();
         mgr->add();
@@ -1194,52 +1194,55 @@ void fgStartReposition()
   fgSetBool("/sim/signals/reinit", true);
   fgSetBool("/sim/crashed", false);
 
-  globals->get_subsystem("flight")->unbind();
+  // Fetch the subsystem manager.
+  auto mgr = globals->get_subsystem_mgr();
+
+  mgr->get_subsystem()->unbind();
 
   // update our position based on current presets
   // this will mark position as needed finalized which we'll do in the
   // main-loop
   flightgear::initPosition();
   
-  auto terraSync = globals->get_subsystem();
+  auto terraSync = mgr->get_subsystem();
   if (terraSync) {
     terraSync->reposition();
   }
   
   // Initialize the FDM
-  globals->get_subsystem()->reinit();
+  mgr->get_subsystem()->reinit();
   
   // reset replay buffers
-  globals->get_subsystem()->reinit();
-  
+  mgr->get_subsystem()->reinit();
+
   // ugly: finalizePosition waits for METAR to arrive for the new airport.
   // we don't re-init the environment manager here, since historically we did
   // not, and doing so seems to have other issues. All that's needed is to
   // schedule METAR fetch immediately, so it's available for finalizePosition.
   // So we manually extract the METAR-fetching component inside the environment
   // manager, and re-init that.
-  SGSubsystemGroup* envMgr = static_cast(globals->get_subsystem("environment"));
+  auto envMgr = static_cast(mgr->get_subsystem());
   if (envMgr) {
     envMgr->get_subsystem("realwx")->reinit();
   }
   
     // needed for parking assignment to work after reposition
-    auto atcManager = globals->get_subsystem();
+    auto atcManager = mgr->get_subsystem();
     if (atcManager) {
         atcManager->reposition();
     }
 
   // need to bind FDMshell again
-  globals->get_subsystem("flight")->bind();
+  mgr->get_subsystem()->bind();
 
   // need to reset aircraft (systems/instruments/autopilot)
   // so they can adapt to current environment
-  globals->get_subsystem("systems")->reinit();
-  globals->get_subsystem("instrumentation")->reinit();
-  globals->get_subsystem("xml-autopilot")->reinit();
+  mgr->get_subsystem()->reinit();
+  mgr->get_subsystem()->reinit();
+  mgr->get_subsystem("xml-autopilot")->reinit();
 
   // need to update the timezone
-  auto timeManager = globals->get_subsystem();
+  auto timeManager = mgr->get_subsystem();
   if (timeManager) {
       timeManager->reposition();
   }
diff --git a/src/Main/fg_scene_commands.cxx b/src/Main/fg_scene_commands.cxx
index fe772d44c..b60fa3e54 100644
--- a/src/Main/fg_scene_commands.cxx
+++ b/src/Main/fg_scene_commands.cxx
@@ -239,7 +239,7 @@ do_tile_cache_reload (const SGPropertyNode * arg, SGPropertyNode * root)
         master_freeze->setBoolValue(true);
     }
 
-    globals->get_subsystem("scenery")->reinit();
+    globals->get_subsystem()->reinit();
 
     if ( !freeze ) {
         master_freeze->setBoolValue(false);
@@ -284,7 +284,7 @@ do_materials_reload (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_dialog_new (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+    auto gui = globals->get_subsystem();
     if (!gui) {
       return false;
     }
@@ -424,7 +424,7 @@ do_dialog_apply (const SGPropertyNode * arg, SGPropertyNode * root)
 static bool
 do_gui_redraw (const SGPropertyNode * arg, SGPropertyNode * root)
 {
-    NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
+    auto gui = globals->get_subsystem();
     gui->redraw();
     return true;
 }
diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index 50311c70b..17c63f75f 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -947,12 +947,12 @@ void FGGlobals::set_warp_delta( long int d )
 
 FGScenery* FGGlobals::get_scenery () const
 {
-    return get_subsystem();
+    return subsystem_mgr->get_subsystem();
 }
 
 FGViewMgr *FGGlobals::get_viewmgr() const
 {
-    return get_subsystem();
+    return subsystem_mgr->get_subsystem();
 }
 
 flightgear::View* FGGlobals::get_current_view () const
@@ -968,7 +968,7 @@ void FGGlobals::set_matlib( SGMaterialLib *m )
 
 FGControls *FGGlobals::get_controls() const
 {
-    return get_subsystem();
+    return subsystem_mgr->get_subsystem();
 }
 
 void FGGlobals::addListenerToCleanup(SGPropertyChangeListener* l)
diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx
index e11fbef5c..2140430be 100644
--- a/src/Main/globals.hxx
+++ b/src/Main/globals.hxx
@@ -161,6 +161,8 @@ private:
 
     SGSharedPtr _packageRoot;
 
+    SGSubsystem *get_subsystem (const char * name) const;
+
 public:
 
     FGGlobals();
@@ -171,8 +173,6 @@ public:
 
     SGSubsystemMgr *get_subsystem_mgr () const;
 
-    SGSubsystem *get_subsystem (const char * name) const;
-
     template
     T* get_subsystem() const
     {
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index 60e9fd8c9..a0819bf5e 100755
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -152,14 +152,16 @@ static void fgMainLoop( void )
 
     frame_signal->fireValueChanged();
 
-    auto timeManager = globals->get_subsystem();
+    // Fetch the subsystem manager.
+    auto mgr = globals->get_subsystem_mgr();
+
     // compute simulated time (allowing for pause, warp, etc) and
     // real elapsed time
     double sim_dt, real_dt;
-    timeManager->computeTimeDeltas(sim_dt, real_dt);
+    mgr->get_subsystem()->computeTimeDeltas(sim_dt, real_dt);
 
     // update all subsystems
-    globals->get_subsystem_mgr()->update(sim_dt);
+    mgr->update(sim_dt);
 
     // flush commands waiting in the queue
     SGCommandMgr::instance()->executedQueuedCommands();
@@ -312,6 +314,9 @@ static void fgIdleFunction ( void ) {
     // our initializations out of the idle callback so that we can get a
     // splash screen up and running right away.
 
+    // Fetch the subsystem manager.
+    auto mgr = globals->get_subsystem_mgr();
+
     if ( idle_state == 0 ) {
         auto camera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
         if (guiInit(camera->getGraphicsContext())) {
@@ -337,7 +342,7 @@ static void fgIdleFunction ( void ) {
     } else if ( idle_state == 4 ) {
         idle_state++;
 
-        globals->get_subsystem_mgr()->add();
+        mgr->add();
 
         // Do some quick general initializations
         if( !fgInitGeneral()) {
@@ -367,14 +372,14 @@ static void fgIdleFunction ( void ) {
 
         simgear::SGModelLib::init(globals->get_fg_root().utf8Str(), globals->get_props());
 
-        auto timeManager = globals->get_subsystem();
+        auto timeManager = mgr->get_subsystem();
         timeManager->init();
 
         ////////////////////////////////////////////////////////////////////
         // Initialize the TG scenery subsystem.
         ////////////////////////////////////////////////////////////////////
 
-        auto scenery = globals->get_subsystem_mgr()->add();
+        auto scenery = mgr->add();
         scenery->init();
         scenery->bind();
 
@@ -401,12 +406,12 @@ static void fgIdleFunction ( void ) {
         idle_state++;
         SGTimeStamp st;
         st.stamp();
-        globals->get_subsystem_mgr()->bind();
+        mgr->bind();
         SG_LOG(SG_GENERAL, SG_INFO, "Binding subsystems took:" << st.elapsedMSec());
 
         fgSplashProgress("init-subsystems");
     } else if ( idle_state == 9 ) {
-        SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
+        SGSubsystem::InitStatus status = mgr->incrementalInit();
         if ( status == SGSubsystem::INIT_DONE) {
           ++idle_state;
           fgSplashProgress("finishing-subsystems");
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index f63d2a874..2d100181f 100644
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
@@ -1628,7 +1628,7 @@ fgOptLoadTape(const char* arg)
             fgGetNode("/sim/signals/fdm-initialized", true)->removeChangeListener( this );
 
             // tell the replay subsystem to load the tape
-            FGReplay* replay = globals->get_subsystem();
+            auto replay = globals->get_subsystem();
             assert(replay);
             SGPropertyNode_ptr arg = new SGPropertyNode();
             arg->setStringValue("tape", _tape.utf8Str() );
diff --git a/src/Main/subsystemFactory.cxx b/src/Main/subsystemFactory.cxx
index 997a181d8..d8fc89897 100644
--- a/src/Main/subsystemFactory.cxx
+++ b/src/Main/subsystemFactory.cxx
@@ -243,7 +243,7 @@ do_reinit (const SGPropertyNode * arg, SGPropertyNode * root)
     } else {
         for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
             std::string name = subsystems[i]->getStringValue();
-            SGSubsystem * subsystem = globals->get_subsystem(name.c_str());
+            SGSubsystem * subsystem = globals->get_subsystem_mgr()->get_subsystem(name.c_str());
             if (subsystem == 0) {
                 result = false;
                 SG_LOG( SG_GENERAL, SG_ALERT,
@@ -272,7 +272,7 @@ do_suspend (const SGPropertyNode * arg, SGPropertyNode * root)
     vector subsystems = arg->getChildren("subsystem");
     for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
         std::string name = subsystems[i]->getStringValue();
-        SGSubsystem * subsystem = globals->get_subsystem(name.c_str());
+        SGSubsystem * subsystem = globals->get_subsystem_mgr()->get_subsystem(name.c_str());
         if (subsystem == 0) {
             result = false;
             SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << " not found");
@@ -296,7 +296,7 @@ do_resume (const SGPropertyNode * arg, SGPropertyNode * root)
     vector subsystems = arg->getChildren("subsystem");
     for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
         std::string name = subsystems[i]->getStringValue();
-        SGSubsystem * subsystem = globals->get_subsystem(name.c_str());
+        SGSubsystem * subsystem = globals->get_subsystem_mgr()->get_subsystem(name.c_str());
         if (subsystem == 0) {
             result = false;
             SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem " << name << " not found");
diff --git a/src/MultiPlayer/MPServerResolver.cxx b/src/MultiPlayer/MPServerResolver.cxx
index 30b4ff8df..d215ed9c6 100644
--- a/src/MultiPlayer/MPServerResolver.cxx
+++ b/src/MultiPlayer/MPServerResolver.cxx
@@ -60,7 +60,7 @@ public:
     INIT, LOADING_SRV_RECORDS, LOAD_NEXT_TXT_RECORD, LOADING_TXT_RECORDS, DONE,
   } _state = INIT;
 
-  FGDNSClient * _dnsClient = globals->get_subsystem ();
+  FGDNSClient* _dnsClient = globals->get_subsystem();
   DNS::Request_ptr _dnsRequest;
   PropertyList _serverNodes;
   PropertyList::const_iterator _serverNodes_it;
diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx
index 1a8020ae1..1c8450e90 100644
--- a/src/MultiPlayer/multiplaymgr.cxx
+++ b/src/MultiPlayer/multiplaymgr.cxx
@@ -52,6 +52,7 @@
 #include "multiplaymgr.hxx"
 #include "mpmessages.hxx"
 #include "MPServerResolver.hxx"
+#include 
 #include 
 #include