From 6bc2f595728571329c094a5a7904e920f325f940 Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Mon, 12 Nov 2001 16:06:29 +0000
Subject: [PATCH] Sync with latest JSBSim CVS

---
 aclocal.m4                                |   2 +-
 src/FDM/JSBSim.cxx                        |   1 -
 src/FDM/JSBSim.hxx                        |   3 +
 src/FDM/JSBSim/FGAerodynamics.cpp         |   6 +-
 src/FDM/JSBSim/FGAircraft.cpp             |   6 +-
 src/FDM/JSBSim/FGAtmosphere.cpp           |  42 +++---
 src/FDM/JSBSim/FGAtmosphere.h             |   2 +
 src/FDM/JSBSim/FGAuxiliary.cpp            |  16 +-
 src/FDM/JSBSim/FGAuxiliary.h              |   8 +-
 src/FDM/JSBSim/FGCoefficient.cpp          |   1 -
 src/FDM/JSBSim/FGCoefficient.h            |   1 -
 src/FDM/JSBSim/FGConfigFile.cpp           |  22 +--
 src/FDM/JSBSim/FGConfigFile.h             |   2 -
 src/FDM/JSBSim/FGEngine.h                 |   1 -
 src/FDM/JSBSim/FGFCS.cpp                  |   2 -
 src/FDM/JSBSim/FGFCS.h                    |  50 +++----
 src/FDM/JSBSim/FGFDMExec.cpp              |   9 +-
 src/FDM/JSBSim/FGFDMExec.h                |  56 ++++---
 src/FDM/JSBSim/FGFactorGroup.cpp          |   1 -
 src/FDM/JSBSim/FGFactorGroup.h            |   1 -
 src/FDM/JSBSim/FGForce.cpp                |   7 +-
 src/FDM/JSBSim/FGInertial.cpp             |  19 ++-
 src/FDM/JSBSim/FGInertial.h               |   9 ++
 src/FDM/JSBSim/FGInitialCondition.cpp     |  40 +++--
 src/FDM/JSBSim/FGInitialCondition.h       |  46 +++---
 src/FDM/JSBSim/FGJSBBase.cpp              | 106 +++++++++++++
 src/FDM/JSBSim/FGJSBBase.h                | 173 ++++++++++++++++++++--
 src/FDM/JSBSim/FGLGear.cpp                |   2 +-
 src/FDM/JSBSim/FGMassBalance.cpp          |   2 +-
 src/FDM/JSBSim/FGModel.h                  |   1 -
 src/FDM/JSBSim/FGPiston.cpp               |   3 +-
 src/FDM/JSBSim/FGPosition.cpp             |  30 ++--
 src/FDM/JSBSim/FGPosition.h               |   2 +
 src/FDM/JSBSim/FGPropulsion.cpp           |  10 +-
 src/FDM/JSBSim/FGRocket.cpp               |   1 -
 src/FDM/JSBSim/FGState.cpp                |  45 +++---
 src/FDM/JSBSim/FGState.h                  |   5 +-
 src/FDM/JSBSim/FGTank.cpp                 |   1 -
 src/FDM/JSBSim/FGTrim.cpp                 |  76 +---------
 src/FDM/JSBSim/FGTrim.h                   |   5 -
 src/FDM/JSBSim/FGTrimAxis.cpp             |  67 ++++-----
 src/FDM/JSBSim/JSBSim.cpp                 |  30 +++-
 src/FDM/JSBSim/filtersjb/FGFCSComponent.h |   1 -
 src/FDM/flight.cxx                        |   6 +-
 src/Main/fg_io.cxx                        |   1 +
 45 files changed, 585 insertions(+), 335 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 78a4037e5..7d5836b91 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4
+dnl aclocal.m4 generated automatically by aclocal 1.4-p4
 
 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx
index ba30c9e41..42bc2c553 100644
--- a/src/FDM/JSBSim.cxx
+++ b/src/FDM/JSBSim.cxx
@@ -49,7 +49,6 @@
 #include <FDM/JSBSim/FGState.h>
 #include <FDM/JSBSim/FGTranslation.h>
 #include <FDM/JSBSim/FGAuxiliary.h>
-#include <FDM/JSBSim/FGDefs.h>
 #include <FDM/JSBSim/FGInitialCondition.h>
 #include <FDM/JSBSim/FGTrim.h>
 #include <FDM/JSBSim/FGAtmosphere.h>
diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx
index b8097093f..6d9f66f34 100644
--- a/src/FDM/JSBSim.hxx
+++ b/src/FDM/JSBSim.hxx
@@ -46,6 +46,9 @@ DEFINITIONS
 
 #define ID_JSBSIMXX "$Header JSBSim.hxx,v 1.4 2000/10/22 14:02:16 jsb Exp $"
 
+#define METERS_TO_FEET 3.2808398950
+#define RADTODEG 57.2957795
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp
index e373f95ad..ed8ac0b7c 100644
--- a/src/FDM/JSBSim/FGAerodynamics.cpp
+++ b/src/FDM/JSBSim/FGAerodynamics.cpp
@@ -108,11 +108,11 @@ bool FGAerodynamics::Run(void)
     vForces = State->GetTs2b(alpha, beta)*vFs;
 
     vDXYZcg(eX) = -(Aircraft->GetXYZrp(eX) 
-                      - MassBalance->GetXYZcg(eX))*INCHTOFT;
+                      - MassBalance->GetXYZcg(eX))*inchtoft;
     vDXYZcg(eY) =  (Aircraft->GetXYZrp(eY) 
-                      - MassBalance->GetXYZcg(eY))*INCHTOFT;
+                      - MassBalance->GetXYZcg(eY))*inchtoft;
     vDXYZcg(eZ) = -(Aircraft->GetXYZrp(eZ) 
-                      - MassBalance->GetXYZcg(eZ))*INCHTOFT;
+                      - MassBalance->GetXYZcg(eZ))*inchtoft;
 
     vMoments = vDXYZcg*vForces; // M = r X F
 
diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp
index b5cfca1c0..44dd4e75e 100644
--- a/src/FDM/JSBSim/FGAircraft.cpp
+++ b/src/FDM/JSBSim/FGAircraft.cpp
@@ -178,7 +178,7 @@ bool FGAircraft::Run(void)
     
     vBodyAccel = vForces/MassBalance->GetMass();
     
-    vNcg = vBodyAccel*INVGRAVITY;
+    vNcg = vBodyAccel/Inertial->gravity();
     
     if (alphaclmax != 0) {
       if (Translation->Getalpha() > 0.85*alphaclmax) {
@@ -414,10 +414,10 @@ void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
   if (debug_lvl > 0)
     cout << "                            Version: " << highint << CFGVersion
                                                              << normint << endl;
-  if (CFGVersion != NEEDED_CFG_VERSION) {
+  if (CFGVersion != needed_cfg_version) {
     cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
             " RESULTS WILL BE UNPREDICTABLE !!" << endl;
-    cerr << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
+    cerr << "Current version needed is: " << needed_cfg_version << endl;
     cerr << "         You have version: " << CFGVersion << endl << fgdef << endl;
   }
 }
diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp
index 085f95b69..1ce5138f7 100644
--- a/src/FDM/JSBSim/FGAtmosphere.cpp
+++ b/src/FDM/JSBSim/FGAtmosphere.cpp
@@ -56,7 +56,6 @@ INCLUDES
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
-#include "FGDefs.h"
 #include "FGMatrix33.h"
 #include "FGColumnVector3.h"
 #include "FGColumnVector4.h"
@@ -84,17 +83,6 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
   htab[6]=200131.234;
   htab[7]=259186.352; //ft.
 
-  Calculate(h);
-  SLtemperature = temperature;
-  SLpressure    = pressure;
-  SLdensity     = density;
-  SLsoundspeed  = sqrt(SHRATIO*Reng*temperature);
-  rSLtemperature = 1.0/temperature;
-  rSLpressure    = 1.0/pressure;
-  rSLdensity     = 1.0/density;
-  rSLsoundspeed  = 1.0/SLsoundspeed;
-  useExternal=false;
-
   if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
 }
 
@@ -107,6 +95,26 @@ FGAtmosphere::~FGAtmosphere()
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+bool FGAtmosphere::InitModel(void)
+{
+  FGModel::InitModel();
+
+  Calculate(h);
+  SLtemperature = temperature;
+  SLpressure    = pressure;
+  SLdensity     = density;
+  SLsoundspeed  = sqrt(SHRatio*Reng*temperature);
+  rSLtemperature = 1.0/temperature;
+  rSLpressure    = 1.0/pressure;
+  rSLdensity     = 1.0/density;
+  rSLsoundspeed  = 1.0/SLsoundspeed;
+  useExternal=false;
+  
+  return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 bool FGAtmosphere::Run(void)
 {
   if (!FGModel::Run()) {                 // if false then execute this Run()
@@ -124,7 +132,7 @@ bool FGAtmosphere::Run(void)
 
     if (psiw < 0) psiw += 2*M_PI;
 
-    soundspeed = sqrt(SHRATIO*Reng*temperature);
+    soundspeed = sqrt(SHRatio*Reng*temperature);
 
     State->Seta(soundspeed);
 
@@ -212,13 +220,13 @@ void FGAtmosphere::Calculate(float altitude)
  
   if (slope == 0) {
     temperature = reftemp;
-    pressure = refpress*exp(-GRAVITY/(reftemp*Reng)*(altitude-htab[i]));
-    //density = refdens*exp(-GRAVITY/(reftemp*Reng)*(altitude-htab[i]));
+    pressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
+    //density = refdens*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
     density = pressure/(Reng*temperature);
   } else {
     temperature = reftemp+slope*(altitude-htab[i]);
-    pressure = refpress*pow(temperature/reftemp,-GRAVITY/(slope*Reng));
-    //density = refdens*pow(temperature/reftemp,-(GRAVITY/(slope*Reng)+1));
+    pressure = refpress*pow(temperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
+    //density = refdens*pow(temperature/reftemp,-(Inertial->SLgravity()/(slope*Reng)+1));
     density = pressure/(Reng*temperature);
   }
   lastIndex=i;
diff --git a/src/FDM/JSBSim/FGAtmosphere.h b/src/FDM/JSBSim/FGAtmosphere.h
index 024969310..431af4d45 100644
--- a/src/FDM/JSBSim/FGAtmosphere.h
+++ b/src/FDM/JSBSim/FGAtmosphere.h
@@ -88,6 +88,8 @@ public:
       @return false if no error */
   bool Run(void);
 
+  bool InitModel(void);
+
   /// Returns the temperature in degrees Rankine.
   inline float GetTemperature(void) {return temperature;}
   /** Returns the density in slugs/ft^3.
diff --git a/src/FDM/JSBSim/FGAuxiliary.cpp b/src/FDM/JSBSim/FGAuxiliary.cpp
index 3131e4799..6c2ee284b 100644
--- a/src/FDM/JSBSim/FGAuxiliary.cpp
+++ b/src/FDM/JSBSim/FGAuxiliary.cpp
@@ -155,7 +155,7 @@ bool FGAuxiliary::Run()
                   + Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt)
                   + Inertial->GetGravity();
 
-    earthPosAngle += State->Getdt()*OMEGA_EARTH;
+    earthPosAngle += State->Getdt()*Inertial->omega();
     return false;
   } else {
     return true;
@@ -190,6 +190,20 @@ float FGAuxiliary::GetCrossWind(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+FGColumnVector3 FGAuxiliary::GetNpilot(void)
+{
+  return vPilotAccel/Inertial->gravity();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGAuxiliary::GetNpilot(int idx)
+{
+  return (vPilotAccel/Inertial->gravity())(idx);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGAuxiliary::GetState(void)
 {
   qbar = Translation->Getqbar();
diff --git a/src/FDM/JSBSim/FGAuxiliary.h b/src/FDM/JSBSim/FGAuxiliary.h
index d8f1dec49..23ef0d7f7 100644
--- a/src/FDM/JSBSim/FGAuxiliary.h
+++ b/src/FDM/JSBSim/FGAuxiliary.h
@@ -86,14 +86,14 @@ public:
 
   // Use FGInitialCondition to set these speeds
   inline float GetVcalibratedFPS(void) { return vcas; }
-  inline float GetVcalibratedKTS(void) { return vcas*FPSTOKTS; }
+  inline float GetVcalibratedKTS(void) { return vcas*fpstokts; }
   inline float GetVequivalentFPS(void) { return veas; }
-  inline float GetVequivalentKTS(void) { return veas*FPSTOKTS; }
+  inline float GetVequivalentKTS(void) { return veas*fpstokts; }
   
   inline FGColumnVector3& GetPilotAccel(void) { return vPilotAccel; }
   inline float GetPilotAccel(int idx) { return vPilotAccel(idx); }
-  inline FGColumnVector3 GetNpilot(void) { return vPilotAccel*INVGRAVITY; }
-  inline float GetNpilot(int idx) { return (vPilotAccel*INVGRAVITY)(idx); }
+  FGColumnVector3 GetNpilot(void);
+  float GetNpilot(int idx);
 
   inline float GetEarthPositionAngle(void) { return earthPosAngle; }
   
diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp
index 4d36094dd..142c90e70 100644
--- a/src/FDM/JSBSim/FGCoefficient.cpp
+++ b/src/FDM/JSBSim/FGCoefficient.cpp
@@ -44,7 +44,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGCoefficient.h"
 #include "FGState.h"
 #include "FGFDMExec.h"
diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h
index 5396be219..b35282b79 100644
--- a/src/FDM/JSBSim/FGCoefficient.h
+++ b/src/FDM/JSBSim/FGCoefficient.h
@@ -45,7 +45,6 @@ INCLUDES
 #include <vector>
 #include <string>
 #include "FGConfigFile.h"
-#include "FGDefs.h"
 #include "FGTable.h"
 #include "FGJSBBase.h"
 
diff --git a/src/FDM/JSBSim/FGConfigFile.cpp b/src/FDM/JSBSim/FGConfigFile.cpp
index 85963b995..42fbe6a32 100644
--- a/src/FDM/JSBSim/FGConfigFile.cpp
+++ b/src/FDM/JSBSim/FGConfigFile.cpp
@@ -64,26 +64,20 @@ string FGConfigFile::GetNextConfigLine(void)
 
   do {
     CurrentLine = GetLine();
-    if ((CurrentLine.find("<COMMENT>") != CurrentLine.npos) ||
-        (CurrentLine.find("<!--") != CurrentLine.npos)) {
+    if (CurrentLine.find("<!--") != CurrentLine.npos) {
       CommentsOn = true;
       CommentString = "";
       if (CurrentLine.find("<!--") != CurrentLine.npos)
         CurrentLine.erase(CurrentLine.find("<!--"),4);
-      else if (CurrentLine.find("<COMMENT>") != CurrentLine.npos)
-        CurrentLine.erase(CurrentLine.find("<COMMENT>"),9);
       while((deblank = CurrentLine.find(" ")) != CurrentLine.npos) CurrentLine.erase(deblank,1);
       if (CurrentLine.size() <= 2) CurrentLine = "";
     }
 
-    if ((CurrentLine.find("</COMMENT>") != CurrentLine.npos) ||
-        (CurrentLine.find("-->") != CurrentLine.npos)) {
+    if (CurrentLine.find("-->") != CurrentLine.npos) {
       CommentsOn = false;
 
       if (CurrentLine.find("-->") != CurrentLine.npos)
         CurrentLine.erase(CurrentLine.find("-->"),4);
-      else if (CurrentLine.find("</COMMENT>") != CurrentLine.npos)
-        CurrentLine.erase(CurrentLine.find("</COMMENT>"),10);
 
       while((deblank = CurrentLine.find(" ")) != CurrentLine.npos) CurrentLine.erase(deblank,1);
       if (CurrentLine.size() <= 2) CurrentLine = "";
@@ -94,7 +88,7 @@ string FGConfigFile::GetNextConfigLine(void)
 
     if (CommentsOn) CommentString += CurrentLine + "\r\n";
 
-  } while (IsCommentLine());
+  } while (CommentsOn);
 
   if (CurrentLine.length() == 0) GetNextConfigLine();
   CurrentIndex = 0;
@@ -186,16 +180,6 @@ string FGConfigFile::GetValue(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGConfigFile::IsCommentLine(void)
-{
-  if (CurrentLine[0] == '/' && CurrentLine[1] == '/') return true;
-  if (CommentsOn) return true;
-
-  return false;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 string FGConfigFile::GetLine(void)
 {
   string scratch = "";
diff --git a/src/FDM/JSBSim/FGConfigFile.h b/src/FDM/JSBSim/FGConfigFile.h
index 60f022de0..12ee643d5 100644
--- a/src/FDM/JSBSim/FGConfigFile.h
+++ b/src/FDM/JSBSim/FGConfigFile.h
@@ -72,7 +72,6 @@ INCLUDES
     using std::string;
 #endif
 
-#include "FGDefs.h"
 #include "FGJSBBase.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -118,7 +117,6 @@ public:
   string GetValue(string);
   string GetValue(void);
   string GetCommentString(void);
-  bool IsCommentLine(void);
   bool IsOpen(void) {return Opened;}
   FGConfigFile& operator>>(double&);
   FGConfigFile& operator>>(float&);
diff --git a/src/FDM/JSBSim/FGEngine.h b/src/FDM/JSBSim/FGEngine.h
index ba5058f8a..ff982cacf 100644
--- a/src/FDM/JSBSim/FGEngine.h
+++ b/src/FDM/JSBSim/FGEngine.h
@@ -245,7 +245,6 @@ protected:
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
-#include "FGDefs.h"
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif
diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp
index 794fbf91f..d84d17e18 100644
--- a/src/FDM/JSBSim/FGFCS.cpp
+++ b/src/FDM/JSBSim/FGFCS.cpp
@@ -37,8 +37,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
-
 #include "FGFCS.h"
 #include "FGState.h"
 #include "FGFDMExec.h"
diff --git a/src/FDM/JSBSim/FGFCS.h b/src/FDM/JSBSim/FGFCS.h
index f2e84eb48..20fb0fa20 100644
--- a/src/FDM/JSBSim/FGFCS.h
+++ b/src/FDM/JSBSim/FGFCS.h
@@ -196,13 +196,13 @@ public:
   /** Gets the throttle command.
       @param engine engine ID number
       @return throttle command in percent ( 0 - 100) for the given engine */
-  float GetThrottleCmd(int engine);
-
-  /** Gets the mixture command.
-      @param engine engine ID number
-      @return mixture command in percent ( 0 - 100) for the given engine */
-  inline float GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
-
+  float GetThrottleCmd(int engine);
+
+  /** Gets the mixture command.
+      @param engine engine ID number
+      @return mixture command in percent ( 0 - 100) for the given engine */
+  inline float GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
+
   /** Gets the pitch trim command.
       @return pitch trim command in radians */
   inline float GetPitchTrimCmd(void) { return PTrimCmd; }
@@ -237,12 +237,12 @@ public:
   /** Gets the throttle position.
       @param engine engine ID number
       @return throttle position for the given engine in percent ( 0 - 100)*/
-  float GetThrottlePos(int engine);
-
-  /** Gets the mixture position.
-      @param engine engine ID number
-      @return mixture position for the given engine in percent ( 0 - 100)*/
-  inline float GetMixturePos(int engine) { return MixturePos[engine]; }
+  float GetThrottlePos(int engine);
+
+  /** Gets the mixture position.
+      @param engine engine ID number
+      @return mixture position for the given engine in percent ( 0 - 100)*/
+  inline float GetMixturePos(int engine) { return MixturePos[engine]; }
   //@}
 
   /** Retrieves the State object pointer.
@@ -300,11 +300,11 @@ public:
       @param engine engine ID number
       @param cmd throttle command in percent (0 - 100)*/
   void SetThrottleCmd(int engine, float cmd);
-
-  /** Sets the mixture command for the specified engine
-      @param engine engine ID number
-      @param cmd mixture command in percent (0 - 100)*/
-  void SetMixtureCmd(int engine, float cmd);
+
+  /** Sets the mixture command for the specified engine
+      @param engine engine ID number
+      @param cmd mixture command in percent (0 - 100)*/
+  void SetMixtureCmd(int engine, float cmd);
   //@}
 
   /// @name Aerosurface position setting
@@ -337,11 +337,11 @@ public:
       @param engine engine ID number
       @param cmd throttle setting in percent (0 - 100)*/
   void SetThrottlePos(int engine, float cmd);
-
-  /** Sets the actual mixture setting for the specified engine
-      @param engine engine ID number
-      @param cmd mixture setting in percent (0 - 100)*/
-  void SetMixturePos(int engine, float cmd);
+
+  /** Sets the actual mixture setting for the specified engine
+      @param engine engine ID number
+      @param cmd mixture setting in percent (0 - 100)*/
+  void SetMixturePos(int engine, float cmd);
   //@}
 
   /// @name Landing Gear brakes
@@ -380,8 +380,8 @@ private:
   float PTrimCmd;
   vector <float> ThrottleCmd;
   vector <float> ThrottlePos;
-  vector <float> MixtureCmd;
-  vector <float> MixturePos;
+  vector <float> MixtureCmd;
+  vector <float> MixturePos;
   float LeftBrake, RightBrake, CenterBrake; // Brake settings
 
   vector <FGFCSComponent*> Components;
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 33adae95c..ac7ed2f51 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -102,6 +102,8 @@ short debug_lvl;  // This describes to any interested entity the debug level
                   // g) 16: When set various parameters are sanity checked and
                   //    a message is printed out when they go out of bounds.
 
+unsigned int FGFDMExec::FDMctr = 0;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -133,6 +135,9 @@ FGFDMExec::FGFDMExec(void)
   modelLoaded = false;
   Scripted = false;
 
+  IdFDM = FDMctr;
+  FDMctr++;
+
   try {
     char* num = getenv("JSBSIM_DEBUG");
     if (!num) debug_lvl = 1;
@@ -143,8 +148,8 @@ FGFDMExec::FGFDMExec(void)
 
   if (debug_lvl > 0) {
     cout << "\n\n     " << highint << underon << "JSBSim Flight Dynamics Model v"
-                                   << JSBSIM_VERSION << underoff << normint << endl;
-    cout << halfint << "            [cfg file spec v" << NEEDED_CFG_VERSION << "]\n\n";
+                                   << JSBSim_version << underoff << normint << endl;
+    cout << halfint << "            [cfg file spec v" << needed_cfg_version << "]\n\n";
     cout << normint << "JSBSim startup beginning ...\n\n";
   }
 
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index c817a6d6b..14062a636 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -71,26 +71,6 @@ class FGAuxiliary;
 class FGOutput;
 class FGInitialCondition;
 
-struct condition {
-  vector <eParam>  TestParam;
-  vector <eParam>  SetParam;
-  vector <float>   TestValue;
-  vector <float>   SetValue;
-  vector <string>  Comparison;
-  vector <float>   TC;
-  vector <bool>    Persistent;
-  vector <eAction> Action;
-  vector <eType>   Type;
-  vector <bool>    Triggered;
-  vector <float>   newValue;
-  vector <float>   OriginalValue;
-  vector <float>   StartTime;
-  vector <float>   EndTime;
-
-  condition() {
-  }
-};
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -299,12 +279,46 @@ public:
   inline string GetAircraftPath(void)        {return AircraftPath;}
 
 private:
+  enum eAction {
+    FG_RAMP  = 1,
+    FG_STEP  = 2,
+    FG_EXP   = 3
+  };
+
+  enum eType {
+    FG_VALUE = 1,
+    FG_DELTA = 2,
+    FG_BOOL  = 3
+  };
+
+  struct condition {
+    vector <eParam>  TestParam;
+    vector <eParam>  SetParam;
+    vector <float>   TestValue;
+    vector <float>   SetValue;
+    vector <string>  Comparison;
+    vector <float>   TC;
+    vector <bool>    Persistent;
+    vector <eAction> Action;
+    vector <eType>   Type;
+    vector <bool>    Triggered;
+    vector <float>   newValue;
+    vector <float>   OriginalValue;
+    vector <float>   StartTime;
+    vector <float>   EndTime;
+
+    condition() {
+    }
+  };
+
   FGModel* FirstModel;
 
   bool frozen;
   bool terminate;
   int  Error;
-  int  Frame;
+  unsigned int Frame;
+  unsigned int IdFDM;
+  static unsigned int FDMctr;
   bool modelLoaded;
   bool Scripted;
 
diff --git a/src/FDM/JSBSim/FGFactorGroup.cpp b/src/FDM/JSBSim/FGFactorGroup.cpp
index bbc4c177b..3d010a113 100644
--- a/src/FDM/JSBSim/FGFactorGroup.cpp
+++ b/src/FDM/JSBSim/FGFactorGroup.cpp
@@ -45,7 +45,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGCoefficient.h"
 #include "FGFactorGroup.h"
 #include "FGState.h"
diff --git a/src/FDM/JSBSim/FGFactorGroup.h b/src/FDM/JSBSim/FGFactorGroup.h
index e524cd200..bb2f8a589 100644
--- a/src/FDM/JSBSim/FGFactorGroup.h
+++ b/src/FDM/JSBSim/FGFactorGroup.h
@@ -45,7 +45,6 @@ INCLUDES
 #include <vector>
 #include <string>
 #include "FGConfigFile.h"
-#include "FGDefs.h"
 #include "FGTable.h"
 #include "FGCoefficient.h"
 #include "FGAerodynamics.h"
diff --git a/src/FDM/JSBSim/FGForce.cpp b/src/FDM/JSBSim/FGForce.cpp
index 567c8f7a9..105a31d42 100644
--- a/src/FDM/JSBSim/FGForce.cpp
+++ b/src/FDM/JSBSim/FGForce.cpp
@@ -46,7 +46,6 @@ and the cg.
 #include "FGMatrix33.h"
 #include "FGColumnVector3.h"
 #include "FGColumnVector4.h"
-#include "FGDefs.h"
 #include "FGForce.h"
 
 static const char *IdSrc = "$Id$";
@@ -89,9 +88,9 @@ FGColumnVector3& FGForce::GetBodyForces(void) {
 
   //find the distance from this vector's location to the cg
   //needs to be done like this to convert from structural to body coords
-  vDXYZ(1) = -(vXYZn(1) - fdmex->GetMassBalance()->GetXYZcg(1))*INCHTOFT;
-  vDXYZ(2) =  (vXYZn(2) - fdmex->GetMassBalance()->GetXYZcg(2))*INCHTOFT;  //cg and rp values are in inches
-  vDXYZ(3) = -(vXYZn(3) - fdmex->GetMassBalance()->GetXYZcg(3))*INCHTOFT;
+  vDXYZ(1) = -(vXYZn(1) - fdmex->GetMassBalance()->GetXYZcg(1))*inchtoft;
+  vDXYZ(2) =  (vXYZn(2) - fdmex->GetMassBalance()->GetXYZcg(2))*inchtoft;  //cg and rp values are in inches
+  vDXYZ(3) = -(vXYZn(3) - fdmex->GetMassBalance()->GetXYZcg(3))*inchtoft;
 
   vM = vMn + vDXYZ*vFb;
 
diff --git a/src/FDM/JSBSim/FGInertial.cpp b/src/FDM/JSBSim/FGInertial.cpp
index a224c3591..0a52d5af4 100644
--- a/src/FDM/JSBSim/FGInertial.cpp
+++ b/src/FDM/JSBSim/FGInertial.cpp
@@ -56,6 +56,13 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex),
   Name = "FGInertial";
 
   vRadius.InitMatrix();
+  
+  // Defaults
+  RotationRate    = 0.00007272205217;
+  GM              = 14.06252720E15;
+  RadiusReference = 20925650.00;
+  gAccelReference = GM/(RadiusReference*RadiusReference);
+  gAccel          = GM/(RadiusReference*RadiusReference);
 
   if (debug_lvl & 2) cout << "Instantiated: FGInertial" << endl;
 }
@@ -75,23 +82,25 @@ bool FGInertial::Run(void)
 
   if (!FGModel::Run()) {
 
+    gAccel = GM / (Position->GetRadius()*Position->GetRadius());
+
     stht = sin(Rotation->GetEuler(eTht));
     ctht = cos(Rotation->GetEuler(eTht));
     sphi = sin(Rotation->GetEuler(ePhi));
     cphi = cos(Rotation->GetEuler(ePhi));
 
-    vGravity(eX) = vForces(eX) = -GRAVITY*stht;
-    vGravity(eY) = vForces(eY) =  GRAVITY*sphi*ctht;
-    vGravity(eZ) = vForces(eZ) =  GRAVITY*cphi*ctht;
+    vGravity(eX) = vForces(eX) = -gravity()*stht;
+    vGravity(eY) = vForces(eY) =  gravity()*sphi*ctht;
+    vGravity(eZ) = vForces(eZ) =  gravity()*cphi*ctht;
     
     // The following equation for vOmegaLocal terms shows the angular velocity
     // calculation _for_the_local_frame_ given the earth's rotation (first set)
     // at the current latitude, and also the component due to the aircraft
     // motion over the curved surface of the earth (second set).
 
-    vOmegaLocal(eX) = OMEGA_EARTH * cos(Position->GetLatitude());
+    vOmegaLocal(eX) = omega() * cos(Position->GetLatitude());
     vOmegaLocal(eY) = 0.0;
-    vOmegaLocal(eZ) = OMEGA_EARTH * -sin(Position->GetLatitude());
+    vOmegaLocal(eZ) = omega() * -sin(Position->GetLatitude());
 
     vOmegaLocal(eX) +=  Position->GetVe() / Position->GetRadius();
     vOmegaLocal(eY) += -Position->GetVn() / Position->GetRadius();
diff --git a/src/FDM/JSBSim/FGInertial.h b/src/FDM/JSBSim/FGInertial.h
index f5be24d22..b4aa56a34 100644
--- a/src/FDM/JSBSim/FGInertial.h
+++ b/src/FDM/JSBSim/FGInertial.h
@@ -77,6 +77,10 @@ public:
   FGColumnVector3& GetGravity(void) {return vGravity;}
   float GetForces(int n) {return vForces(n);}
   bool LoadInertial(FGConfigFile* AC_cfg);
+  double SLgravity(void) {return gAccelReference;}
+  double gravity(void) {return gAccel;}
+  double omega(void) {return RotationRate;}
+  double RefRadius(void) {return RadiusReference;}
 
 private:
   void Debug(void);
@@ -84,6 +88,11 @@ private:
   FGColumnVector3 vForces;
   FGColumnVector3 vRadius;
   FGColumnVector3 vGravity;
+  double gAccel;
+  double gAccelReference;
+  double RadiusReference;
+  double RotationRate;
+  double GM;
 };
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/FGInitialCondition.cpp b/src/FDM/JSBSim/FGInitialCondition.cpp
index 3b53a74b9..06c0259e4 100644
--- a/src/FDM/JSBSim/FGInitialCondition.cpp
+++ b/src/FDM/JSBSim/FGInitialCondition.cpp
@@ -53,7 +53,6 @@ INCLUDES
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
-#include "FGDefs.h"
 #include "FGConfigFile.h"
 
 static const char *IdSrc = "$Id$";
@@ -61,8 +60,8 @@ static const char *IdHdr = ID_INITIALCONDITION;
 
 //******************************************************************************
 
-FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec){
-
+FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec)
+{
   vt=vc=ve=vg=0;
   mach=0;
   alpha=beta=gamma=0;
@@ -77,10 +76,9 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec){
   wdir=wmag=0;
   lastSpeedSet=setvt;
   lastWindSet=setwned;
-  sea_level_radius = EARTHRAD;
-  radius_to_vehicle = EARTHRAD;
+  sea_level_radius = FDMExec->GetInertial()->RefRadius();
+  radius_to_vehicle = FDMExec->GetInertial()->RefRadius();
   terrain_altitude = 0;
-  
 
   salpha=sbeta=stheta=sphi=spsi=sgamma=0;
   calpha=cbeta=ctheta=cphi=cpsi=cgamma=1;
@@ -107,13 +105,13 @@ FGInitialCondition::~FGInitialCondition()
 
 void FGInitialCondition::SetVcalibratedKtsIC(float tt) {
 
-  if(getMachFromVcas(&mach,tt*jsbKTSTOFPS)) {
+  if(getMachFromVcas(&mach,tt*ktstofps)) {
     //cout << "Mach: " << mach << endl;
     lastSpeedSet=setvc;
-    vc=tt*jsbKTSTOFPS;
+    vc=tt*ktstofps;
     vt=mach*fdmex->GetAtmosphere()->GetSoundSpeed();
     ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
-    //cout << "Vt: " << vt*jsbFPSTOKTS << " Vc: " << vc*jsbFPSTOKTS << endl;
+    //cout << "Vt: " << vt*fpstokts << " Vc: " << vc*fpstokts << endl;
   }
   else {
     cout << "Failed to get Mach number for given Vc and altitude, Vc unchanged." << endl;
@@ -124,7 +122,7 @@ void FGInitialCondition::SetVcalibratedKtsIC(float tt) {
 //******************************************************************************
 
 void FGInitialCondition::SetVequivalentKtsIC(float tt) {
-  ve=tt*jsbKTSTOFPS;
+  ve=tt*ktstofps;
   lastSpeedSet=setve;
   vt=ve*1/sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
   mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
@@ -170,7 +168,7 @@ void FGInitialCondition::SetMachIC(float tt) {
   vt=mach*fdmex->GetAtmosphere()->GetSoundSpeed();
   vc=calcVcas(mach);
   ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio());
-  //cout << "Vt: " << vt*jsbFPSTOKTS << " Vc: " << vc*jsbFPSTOKTS << endl;
+  //cout << "Vt: " << vt*fpstokts << " Vc: " << vc*fpstokts << endl;
 }
 
 //******************************************************************************
@@ -306,7 +304,7 @@ void FGInitialCondition::SetWindNEDFpsIC(float wN, float wE, float wD ) {
 
 // positive from left
 void FGInitialCondition::SetHeadWindKtsIC(float head){ 
-    whead=head*KTSTOFPS;
+    whead=head*ktstofps;
     lastWindSet=setwhc; 
     calcWindUVW();
     if(lastSpeedSet == setvg)
@@ -317,7 +315,7 @@ void FGInitialCondition::SetHeadWindKtsIC(float head){
 //******************************************************************************
 
 void FGInitialCondition::SetCrossWindKtsIC(float cross){ 
-    wcross=cross*KTSTOFPS; 
+    wcross=cross*ktstofps; 
     lastWindSet=setwhc; 
     calcWindUVW();
     if(lastSpeedSet == setvg)
@@ -337,7 +335,7 @@ void FGInitialCondition::SetWindDownKtsIC(float wD) {
 //******************************************************************************
 
 void FGInitialCondition::SetWindMagKtsIC(float mag) {
-  wmag=mag*KTSTOFPS;
+  wmag=mag*ktstofps;
   lastWindSet=setwmd;
   calcWindUVW();    
   if(lastSpeedSet == setvg)
@@ -347,7 +345,7 @@ void FGInitialCondition::SetWindMagKtsIC(float mag) {
 //******************************************************************************
 
 void FGInitialCondition::SetWindDirDegIC(float dir) {
-  wdir=dir*DEGTORAD;
+  wdir=dir*degtorad;
   lastWindSet=setwmd;
   calcWindUVW();    
   if(lastSpeedSet == setvg)
@@ -401,13 +399,13 @@ void FGInitialCondition::SetAltitudeFtIC(float tt) {
   case setned:
   case setuvw:
   case setvt:
-    SetVtrueKtsIC(vt*jsbFPSTOKTS);
+    SetVtrueKtsIC(vt*fpstokts);
     break;
   case setvc:
-    SetVcalibratedKtsIC(vc*jsbFPSTOKTS);
+    SetVcalibratedKtsIC(vc*fpstokts);
     break;
   case setve:
-    SetVequivalentKtsIC(ve*jsbFPSTOKTS);
+    SetVequivalentKtsIC(ve*fpstokts);
     break;
   case setmach:
     SetMachIC(mach);
@@ -601,7 +599,7 @@ float FGInitialCondition::calcVcas(float Mach) {
 
   A = pow(((pt-p)/psl+1),0.28571);
   vcas = sqrt(7*psl/rhosl*(A-1));
-  //cout << "calcVcas: vcas= " << vcas*jsbFPSTOKTS << " mach= " << Mach << " pressure: " << pt << endl;
+  //cout << "calcVcas: vcas= " << vcas*fpstokts << " mach= " << Mach << " pressure: " << pt << endl;
   return vcas;
 }
 
@@ -691,7 +689,7 @@ bool FGInitialCondition::solve(float *y,float x)
     *y=x2;
   }
 
-  //cout << "Success= " << success << " Vcas: " << vcas*jsbFPSTOKTS << " Mach: " << x2 << endl;
+  //cout << "Success= " << success << " Vcas: " << vcas*fpstokts << " Mach: " << x2 << endl;
   return success;
 }
 
@@ -699,7 +697,7 @@ bool FGInitialCondition::solve(float *y,float x)
 
 float FGInitialCondition::GetWindDirDegIC(void) {
   if(weast != 0.0) 
-    return atan2(weast,wnorth)*RADTODEG;
+    return atan2(weast,wnorth)*radtodeg;
   else if(wnorth > 0) 
     return 0.0;
   else
diff --git a/src/FDM/JSBSim/FGInitialCondition.h b/src/FDM/JSBSim/FGInitialCondition.h
index 5481148ff..bc39d56a6 100644
--- a/src/FDM/JSBSim/FGInitialCondition.h
+++ b/src/FDM/JSBSim/FGInitialCondition.h
@@ -59,8 +59,6 @@ DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #define ID_INITIALCONDITION "$Id$"
-#define jsbFPSTOKTS 0.5924838
-#define jsbKTSTOFPS 1.6878099
 
 typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
 typedef enum { setwned, setwmd, setwhc } windset; 
@@ -144,19 +142,19 @@ public:
 
   void SetVcalibratedKtsIC(float tt);
   void SetVequivalentKtsIC(float tt);
-  inline void SetVtrueKtsIC(float tt)   { SetVtrueFpsIC(tt*jsbKTSTOFPS);   }
-  inline void SetVgroundKtsIC(float tt) { SetVgroundFpsIC(tt*jsbKTSTOFPS); }
+  inline void SetVtrueKtsIC(float tt)   { SetVtrueFpsIC(tt*ktstofps);   }
+  inline void SetVgroundKtsIC(float tt) { SetVgroundFpsIC(tt*ktstofps); }
   void SetMachIC(float tt);
   
-  inline void SetAlphaDegIC(float tt)      { SetAlphaRadIC(tt*DEGTORAD); }
-  inline void SetBetaDegIC(float tt)       { SetBetaRadIC(tt*DEGTORAD);}
+  inline void SetAlphaDegIC(float tt)      { SetAlphaRadIC(tt*degtorad); }
+  inline void SetBetaDegIC(float tt)       { SetBetaRadIC(tt*degtorad);}
   
-  inline void SetPitchAngleDegIC(float tt) { SetPitchAngleRadIC(tt*DEGTORAD); }
-  inline void SetRollAngleDegIC(float tt)  { SetRollAngleRadIC(tt*DEGTORAD);}
-  inline void SetTrueHeadingDegIC(float tt){ SetTrueHeadingRadIC(tt*DEGTORAD); }
+  inline void SetPitchAngleDegIC(float tt) { SetPitchAngleRadIC(tt*degtorad); }
+  inline void SetRollAngleDegIC(float tt)  { SetRollAngleRadIC(tt*degtorad);}
+  inline void SetTrueHeadingDegIC(float tt){ SetTrueHeadingRadIC(tt*degtorad); }
   
   void SetClimbRateFpmIC(float tt);
-  inline void SetFlightPathAngleDegIC(float tt) { SetFlightPathAngleRadIC(tt*DEGTORAD); }
+  inline void SetFlightPathAngleDegIC(float tt) { SetFlightPathAngleRadIC(tt*degtorad); }
 
   void SetAltitudeFtIC(float tt);
   void SetAltitudeAGLFtIC(float tt);
@@ -164,28 +162,28 @@ public:
   void SetSeaLevelRadiusFtIC(double tt);
   void SetTerrainAltitudeFtIC(double tt);
 
-  inline void SetLatitudeDegIC(float tt)  { latitude=tt*DEGTORAD; }
-  inline void SetLongitudeDegIC(float tt) { longitude=tt*DEGTORAD; }
+  inline void SetLatitudeDegIC(float tt)  { latitude=tt*degtorad; }
+  inline void SetLongitudeDegIC(float tt) { longitude=tt*degtorad; }
 
   
-  inline float GetVcalibratedKtsIC(void) { return vc*jsbFPSTOKTS; }
-  inline float GetVequivalentKtsIC(void) { return ve*jsbFPSTOKTS; }
-  inline float GetVgroundKtsIC(void) { return vg*jsbFPSTOKTS; }
-  inline float GetVtrueKtsIC(void) { return vt*jsbFPSTOKTS; }
+  inline float GetVcalibratedKtsIC(void) { return vc*fpstokts; }
+  inline float GetVequivalentKtsIC(void) { return ve*fpstokts; }
+  inline float GetVgroundKtsIC(void) { return vg*fpstokts; }
+  inline float GetVtrueKtsIC(void) { return vt*fpstokts; }
   inline float GetMachIC(void) { return mach; }
   
   inline float GetClimbRateFpmIC(void) { return hdot*60; }
-  inline float GetFlightPathAngleDegIC(void) { return gamma*RADTODEG; }
+  inline float GetFlightPathAngleDegIC(void) { return gamma*radtodeg; }
   
-  inline float GetAlphaDegIC(void)      { return alpha*RADTODEG; }
-  inline float GetBetaDegIC(void)       { return beta*RADTODEG; }
+  inline float GetAlphaDegIC(void)      { return alpha*radtodeg; }
+  inline float GetBetaDegIC(void)       { return beta*radtodeg; }
   
-  inline float GetPitchAngleDegIC(void) { return theta*RADTODEG; }
-  inline float GetRollAngleDegIC(void) { return phi*RADTODEG; }
-  inline float GetHeadingDegIC(void)   { return psi*RADTODEG; }
+  inline float GetPitchAngleDegIC(void) { return theta*radtodeg; }
+  inline float GetRollAngleDegIC(void) { return phi*radtodeg; }
+  inline float GetHeadingDegIC(void)   { return psi*radtodeg; }
 
-  inline float GetLatitudeDegIC(void)  { return latitude*RADTODEG; }
-  inline float GetLongitudeDegIC(void) { return longitude*RADTODEG; }
+  inline float GetLatitudeDegIC(void)  { return latitude*radtodeg; }
+  inline float GetLongitudeDegIC(void) { return longitude*radtodeg; }
   
   inline float GetAltitudeFtIC(void) { return altitude; }
   inline float GetAltitudeAGLFtIC(void) { return altitude - terrain_altitude; }
diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp
index 1b8a36d49..786b57c31 100644
--- a/src/FDM/JSBSim/FGJSBBase.cpp
+++ b/src/FDM/JSBSim/FGJSBBase.cpp
@@ -56,5 +56,111 @@ char FGJSBBase::fgred[6]    = {27, '[', '3', '1', 'm', '\0' };
 char FGJSBBase::fggreen[6]  = {27, '[', '3', '2', 'm', '\0' };
 char FGJSBBase::fgdef[6]    = {27, '[', '3', '9', 'm', '\0' };
 
+const double FGJSBBase::radtodeg = 57.29578;
+const double FGJSBBase::degtorad = 1.745329E-2;
+const double FGJSBBase::hptoftlbssec = 550.0;
+const double FGJSBBase::fpstokts = 0.592484;
+const double FGJSBBase::ktstofps = 1.68781;
+const double FGJSBBase::inchtoft = 0.08333333;
+const double FGJSBBase::Reng = 1716.0;
+const double FGJSBBase::SHRatio = 1.40;
+const string FGJSBBase::needed_cfg_version = "1.55";
+const string FGJSBBase::JSBSim_version = "0.9.1";
+
+queue <struct FGJSBBase::Message*> FGJSBBase::Messages;
+struct FGJSBBase::Message FGJSBBase::localMsg;
+unsigned int FGJSBBase::messageId = 0; 
+
 short FGJSBBase::debug_lvl  = 0;
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGJSBBase::FGJSBBase()
+{
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::PutMessage(struct Message* msg)
+{
+  Messages.push(msg);
+  return msg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::PutMessage(string text)
+{
+  struct Message *msg = new Message();
+  msg->text = text;
+  msg->messageId = messageId++;
+  msg->subsystem = "FDM";
+  msg->type = Message::eText;
+  Messages.push(msg);
+  return msg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::PutMessage(string text, bool bVal)
+{
+  struct Message *msg = new Message();
+  msg->text = text;
+  msg->messageId = messageId++;
+  msg->subsystem = "FDM";
+  msg->type = Message::eBool;
+  msg->bVal = bVal;
+  Messages.push(msg);
+  return msg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::PutMessage(string text, int iVal)
+{
+  struct Message *msg = new Message();
+  msg->text = text;
+  msg->messageId = messageId++;
+  msg->subsystem = "FDM";
+  msg->type = Message::eInteger;
+  msg->bVal = iVal;
+  Messages.push(msg);
+  return msg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::PutMessage(string text, double dVal)
+{
+  struct Message *msg = new Message();
+  msg->text = text;
+  msg->messageId = messageId++;
+  msg->subsystem = "FDM";
+  msg->type = Message::eDouble;
+  msg->bVal = dVal;
+  Messages.push(msg);
+  return msg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::ReadMessage(void)
+{
+  if (!Messages.empty()) return Messages.front();
+  else                   return NULL;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+struct FGJSBBase::Message* FGJSBBase::ProcessMessage(void)
+{
+  if (!Messages.empty())
+    localMsg = *(Messages.front());
+  else 
+    return NULL;
+  Messages.pop();
+  return &localMsg;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h
index a852258e0..5561886de 100644
--- a/src/FDM/JSBSim/FGJSBBase.h
+++ b/src/FDM/JSBSim/FGJSBBase.h
@@ -41,11 +41,18 @@ INCLUDES
 #ifdef FGFS
 #  include <simgear/compiler.h>
 #  include <math.h>
+#  include <queue>
+#  include STL_STRING
+  SG_USING_STD(queue);
 #else
 #  if defined(sgi) && !defined(__GNUC__)
 #    include <math.h>
+#    include <queue.h>
+#    include <string.h>
 #  else
 #    include <cmath>
+#    include <queue>
+#    include <string>
 #  endif
 #endif
 
@@ -64,6 +71,66 @@ DEFINITIONS
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+enum eParam {
+  FG_UNDEF = 0,
+  FG_TIME,
+  FG_QBAR,
+  FG_WINGAREA,
+  FG_WINGSPAN,
+  FG_CBAR,
+  FG_ALPHA,
+  FG_ALPHADOT,
+  FG_BETA,
+  FG_ABETA,
+  FG_BETADOT,
+  FG_PHI,
+  FG_THT,
+  FG_PSI,
+  FG_PITCHRATE,
+  FG_ROLLRATE,
+  FG_YAWRATE,
+  FG_CL_SQRD,
+  FG_MACH,
+  FG_ALTITUDE,
+  FG_BI2VEL,
+  FG_CI2VEL,
+  FG_ELEVATOR_POS,
+  FG_AILERON_POS,
+  FG_RUDDER_POS,
+  FG_SPDBRAKE_POS,
+  FG_SPOILERS_POS,
+  FG_FLAPS_POS,
+  FG_ELEVATOR_CMD,
+  FG_AILERON_CMD,
+  FG_RUDDER_CMD,
+  FG_SPDBRAKE_CMD,
+  FG_SPOILERS_CMD,
+  FG_FLAPS_CMD,
+  FG_THROTTLE_CMD,
+  FG_THROTTLE_POS,
+  FG_MIXTURE_CMD,
+  FG_MIXTURE_POS,
+  FG_MAGNETO_CMD,
+  FG_STARTER_CMD,
+  FG_ACTIVE_ENGINE,
+  FG_HOVERB,
+  FG_PITCH_TRIM_CMD,
+  FG_YAW_TRIM_CMD,
+  FG_ROLL_TRIM_CMD,
+  FG_LEFT_BRAKE_CMD,
+  FG_CENTER_BRAKE_CMD,
+  FG_RIGHT_BRAKE_CMD,
+  FG_SET_LOGGING,
+  FG_ALPHAH,
+  FG_ALPHAW,
+  FG_LBARH,     //normalized horizontal tail arm
+  FG_LBARV,     //normalized vertical tail arm
+  FG_HTAILAREA,
+  FG_VTAILAREA,
+  FG_VBARH,    //horizontal tail volume 
+  FG_VBARV     //vertical tail volume 
+};
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -84,37 +151,123 @@ CLASS DECLARATION
 class FGJSBBase {
 public:
   /// Constructor for FGJSBBase.
-  FGJSBBase() {};
+  FGJSBBase();
 
-  /// Destructor for FGJSBBase
+  /// Destructor for FGJSBBase.
   virtual ~FGJSBBase() {};
 
-  enum {eL     = 1, eM,     eN    };
-  enum {eP     = 1, eQ,     eR    };
-  enum {eU     = 1, eV,     eW    };
-  enum {eX     = 1, eY,     eZ    };
-  enum {ePhi   = 1, eTht,   ePsi  };
-  enum {eDrag  = 1, eSide,  eLift };
-  enum {eRoll  = 1, ePitch, eYaw  };
-  enum {eNorth = 1, eEast,  eDown };
+  /// JSBSim Message structure
+  struct Message {
+    unsigned int fdmId;
+    unsigned int messageId;
+    string text;
+    string subsystem;
+    enum mType {eText, eInteger, eDouble, eBool} type;
+    bool bVal;
+    int  iVal;
+    double dVal;
+  };
 
+  ///@name JSBSim Enums.
+  //@{
+  /// Moments L, M, N
+  enum {eL     = 1, eM,     eN    };
+  /// Rates P, Q, R
+  enum {eP     = 1, eQ,     eR    };
+  /// Velocities U, V, W
+  enum {eU     = 1, eV,     eW    };
+  /// Positions X, Y, Z
+  enum {eX     = 1, eY,     eZ    };
+  /// Euler angles Phi, Theta, Psi
+  enum {ePhi   = 1, eTht,   ePsi  };
+  /// Stability axis forces, Drag, Side force, Lift
+  enum {eDrag  = 1, eSide,  eLift };
+  /// Local frame orientation Roll, Pitch, Yaw
+  enum {eRoll  = 1, ePitch, eYaw  };
+  /// Local frame position North, East, Down
+  enum {eNorth = 1, eEast,  eDown };
+  //@}
+  
+  ///@name JSBSim console output highlighting terms.
+  //@{
+  /// highlights text
   static char highint[5];
+  /// low intensity text
   static char halfint[5];
+  /// normal intensity text
   static char normint[6];
+  /// resets text properties
   static char reset[5];
+  /// underlines text
   static char underon[5];
+  /// underline off
   static char underoff[6];
+  /// blue text
   static char fgblue[6];
+  /// cyan text
   static char fgcyan[6];
+  /// red text
   static char fgred[6];
+  /// green text
   static char fggreen[6];
+  /// default text
   static char fgdef[6];
+  //@}
+
+  ///@name JSBSim Messaging functions
+  //@{
+  /** Places a Message structure on the Message queue.
+      @param msg pointer to a Message structure
+      @return pointer to a Message structure */
+  struct Message* PutMessage(struct Message* msg);
+  /** Creates a message with the given text and places it on the queue.
+      @param text message text
+      @return pointer to a Message structure */
+  struct Message* PutMessage(string text);
+  /** Creates a message with the given text and boolean value and places it on the queue.
+      @param text message text
+      @param bVal boolean value associated with the message
+      @return pointer to a Message structure */
+  struct Message* PutMessage(string text, bool bVal);
+  /** Creates a message with the given text and integer value and places it on the queue.
+      @param text message text
+      @param iVal integer value associated with the message
+      @return pointer to a Message structure */
+  struct Message* PutMessage(string text, int iVal);
+  /** Creates a message with the given text and double value and places it on the queue.
+      @param text message text
+      @param dVal double value associated with the message
+      @return pointer to a Message structure */
+  struct Message* PutMessage(string text, double dVal);
+  /** Reads the message on the queue (but does not delete it).
+      @return pointer to a Message structure (or NULL if no mesage) */
+  struct Message* ReadMessage(void);
+  /** Reads the message on the queue and removes it from the queue.
+      @return pointer to a Message structure (or NULL if no mesage) */
+  struct Message* ProcessMessage(void);
+  //@}
 
 protected:
+  static struct Message localMsg;
+  
+  static queue <struct Message*> Messages;
+
   virtual void Debug(void) {};
 
   static short debug_lvl;
   static int frame;
+  static unsigned int messageId;
+  
+  static const double radtodeg;
+  static const double degtorad;
+  static const double hptoftlbssec;
+  static const double fpstokts;
+  static const double ktstofps;
+  static const double inchtoft;
+  static const double Reng;         // Specific Gas Constant,ft^2/(sec^2*R)
+  static const double SHRatio;
+  static const string needed_cfg_version;
+  static const string JSBSim_version;
 };
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/FGLGear.cpp b/src/FDM/JSBSim/FGLGear.cpp
index fc418fe5a..ce0c0f8e8 100644
--- a/src/FDM/JSBSim/FGLGear.cpp
+++ b/src/FDM/JSBSim/FGLGear.cpp
@@ -306,7 +306,7 @@ FGColumnVector3& FGLGear::Force(void)
     if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) {
       WheelSlip = 0.0;
     } else {
-      WheelSlip = RADTODEG*atan2(SideWhlVel, RollingWhlVel);
+      WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
     }
 
 // The following code normalizes the wheel velocity vector, reverses it, and zeroes out
diff --git a/src/FDM/JSBSim/FGMassBalance.cpp b/src/FDM/JSBSim/FGMassBalance.cpp
index da8124d62..f6f87391d 100644
--- a/src/FDM/JSBSim/FGMassBalance.cpp
+++ b/src/FDM/JSBSim/FGMassBalance.cpp
@@ -70,7 +70,7 @@ bool FGMassBalance::Run(void)
 
     Weight = EmptyWeight + Propulsion->GetTanksWeight();
 
-    Mass = Weight / GRAVITY;
+    Mass = Weight / Inertial->gravity();
 
 // Calculate new CG here.
 
diff --git a/src/FDM/JSBSim/FGModel.h b/src/FDM/JSBSim/FGModel.h
index 3ba25c1c4..59d3224bd 100644
--- a/src/FDM/JSBSim/FGModel.h
+++ b/src/FDM/JSBSim/FGModel.h
@@ -38,7 +38,6 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGJSBBase.h"
 
 #ifdef FGFS
diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp
index e7a314f2b..57fc8aace 100644
--- a/src/FDM/JSBSim/FGPiston.cpp
+++ b/src/FDM/JSBSim/FGPiston.cpp
@@ -38,7 +38,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGPiston.h"
 #include "FGPropulsion.h"
 
@@ -194,7 +193,7 @@ float FGPiston::Calculate(float PowerRequired)
     HP = 0;
   }
 
-  PowerAvailable = (HP * HPTOFTLBSSEC) - PowerRequired;
+  PowerAvailable = (HP * hptoftlbssec) - PowerRequired;
   return PowerAvailable;
 }
 
diff --git a/src/FDM/JSBSim/FGPosition.cpp b/src/FDM/JSBSim/FGPosition.cpp
index 6e0b008bf..8e7bf1e96 100644
--- a/src/FDM/JSBSim/FGPosition.cpp
+++ b/src/FDM/JSBSim/FGPosition.cpp
@@ -105,14 +105,6 @@ FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
   lastLongitudeDot = lastLatitudeDot = lastRadiusDot = 0.0;
   Longitude = Latitude = 0.0;
   gamma = Vt = Vground = 0.0;
-  h = 3.0;                                 // Est. height of aircraft cg off runway
-  SeaLevelRadius = EARTHRAD;               // For initialization ONLY
-  Radius         = SeaLevelRadius + h;
-  RunwayRadius   = SeaLevelRadius;
-  DistanceAGL    = Radius - RunwayRadius;  // Geocentric
-  vRunwayNormal(3) = -1.0;                 // Initialized for standalone mode
-  b =1;
-  
 
   if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
 }
@@ -124,16 +116,32 @@ FGPosition::~FGPosition()
   if (debug_lvl & 2) cout << "Destroyed:    FGPosition" << endl;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGPosition::InitModel(void)
+{
+  FGModel::InitModel();
+
+  h = 3.0;                                 // Est. height of aircraft cg off runway
+  SeaLevelRadius = Inertial->RefRadius();  // For initialization ONLY
+  Radius         = SeaLevelRadius + h;
+  RunwayRadius   = SeaLevelRadius;
+  DistanceAGL    = Radius - RunwayRadius;  // Geocentric
+  vRunwayNormal(3) = -1.0;                 // Initialized for standalone mode
+  b = 1;
+  return true;
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 /*
 Purpose: Called on a schedule to perform Positioning algorithms
 Notes:   [TP] Make sure that -Vt <= hdot <= Vt, which, of course, should always
          be the case
-         [JB] Run in standalone mode, SeaLevelRadius will be EARTHRAD. In FGFS,
-         SeaLevelRadius is stuffed from FGJSBSim in JSBSim.cxx each pass.
+         [JB] Run in standalone mode, SeaLevelRadius will be reference radius.
+	       In FGFS, SeaLevelRadius is stuffed from FGJSBSim in JSBSim.cxx each pass.
 */
 
-bool FGPosition:: Run(void) {
+bool FGPosition::Run(void) {
   double cosLat;
   double hdot_Vt;
 
diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h
index ca455cacd..0c5ba2794 100644
--- a/src/FDM/JSBSim/FGPosition.h
+++ b/src/FDM/JSBSim/FGPosition.h
@@ -78,6 +78,8 @@ public:
   /// Destructor
   ~FGPosition();
 
+  bool InitModel(void);
+
   /** Runs the Position model; called by the Executive
       @see JSBSim.cpp documentation
       @return false if no error */
diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp
index 3748aa068..e8830e12e 100644
--- a/src/FDM/JSBSim/FGPropulsion.cpp
+++ b/src/FDM/JSBSim/FGPropulsion.cpp
@@ -472,7 +472,7 @@ float FGPropulsion::GetTanksIxx(const FGColumnVector3& vXYZcg)
   float I = 0.0;
   iTank = Tanks.begin();
   while (iTank < Tanks.end()) {
-    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetX() - vXYZcg(eX)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetX() - vXYZcg(eX)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
     iTank++;
   }
   return I;
@@ -485,7 +485,7 @@ float FGPropulsion::GetTanksIyy(const FGColumnVector3& vXYZcg)
   float I = 0.0;
   iTank = Tanks.begin();
   while (iTank < Tanks.end()) {
-    I += ((*iTank)->GetY() - vXYZcg(eY))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    I += ((*iTank)->GetY() - vXYZcg(eY))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
     iTank++;
   }
   return I;
@@ -498,7 +498,7 @@ float FGPropulsion::GetTanksIzz(const FGColumnVector3& vXYZcg)
   float I = 0.0;
   iTank = Tanks.begin();
   while (iTank < Tanks.end()) {
-    I += ((*iTank)->GetZ() - vXYZcg(eZ))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    I += ((*iTank)->GetZ() - vXYZcg(eZ))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
     iTank++;
   }
   return I;
@@ -511,7 +511,7 @@ float FGPropulsion::GetTanksIxz(const FGColumnVector3& vXYZcg)
   float I = 0.0;
   iTank = Tanks.begin();
   while (iTank < Tanks.end()) {
-    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
     iTank++;
   }
   return I;
@@ -524,7 +524,7 @@ float FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg)
   float I = 0.0;
   iTank = Tanks.begin();
   while (iTank != Tanks.end()) {
-    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*Inertial->gravity());
     iTank++;
   }
   return I;
diff --git a/src/FDM/JSBSim/FGRocket.cpp b/src/FDM/JSBSim/FGRocket.cpp
index da96b0cef..416cbbfb8 100644
--- a/src/FDM/JSBSim/FGRocket.cpp
+++ b/src/FDM/JSBSim/FGRocket.cpp
@@ -38,7 +38,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGRocket.h"
 
 static const char *IdSrc = "$Id$";
diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp
index 84ef65274..2c673bca9 100644
--- a/src/FDM/JSBSim/FGState.cpp
+++ b/src/FDM/JSBSim/FGState.cpp
@@ -66,7 +66,7 @@ CLASS IMPLEMENTATION
 //
 // For every term registered here there must be a corresponding handler in
 // GetParameter() below that retrieves that parameter. Also, there must be an
-// entry in the enum eParam definition in FGDefs.h. The ID is what must be used
+// entry in the enum eParam definition in FGJSBBase.h. The ID is what must be used
 // in any config file entry which references that item.
 
 FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
@@ -107,6 +107,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
   RegisterVariable(FG_ALPHA,          " alpha "          );
   RegisterVariable(FG_ALPHADOT,       " alphadot "       );
   RegisterVariable(FG_BETA,           " beta "           );
+  RegisterVariable(FG_ABETA,          " |beta| "         );
   RegisterVariable(FG_BETADOT,        " betadot "        );
   RegisterVariable(FG_PHI,            " roll_angle "     );
   RegisterVariable(FG_THT,            " pitch_angle "    );
@@ -199,6 +200,8 @@ float FGState::GetParameter(eParam val_idx) {
     return Translation->Getadot();
   case FG_BETA:
     return Translation->Getbeta();
+  case FG_ABETA:
+    return fabs(Translation->Getbeta());   
   case FG_BETADOT:
     return Translation->Getbdot();
   case FG_PHI:
@@ -441,15 +444,15 @@ bool FGState::Reset(string path, string acname, string fname)
   }
   
   
-  Position->SetLatitude(latitude*DEGTORAD);
-  Position->SetLongitude(longitude*DEGTORAD);
+  Position->SetLatitude(latitude*degtorad);
+  Position->SetLongitude(longitude*degtorad);
   Position->Seth(h);
 
-  wnorth = wmag*KTSTOFPS*cos(wdir*DEGTORAD);
-  weast = wmag*KTSTOFPS*sin(wdir*DEGTORAD);
+  wnorth = wmag*ktstofps*cos(wdir*degtorad);
+  weast = wmag*ktstofps*sin(wdir*degtorad);
   
-  Initialize(U, V, W, phi*DEGTORAD, tht*DEGTORAD, psi*DEGTORAD,
-               latitude*DEGTORAD, longitude*DEGTORAD, h, wnorth, weast, 0.0);
+  Initialize(U, V, W, phi*degtorad, tht*degtorad, psi*degtorad,
+               latitude*degtorad, longitude*degtorad, h, wnorth, weast, 0.0);
 
   return true;
 }
@@ -715,41 +718,41 @@ void FGState::ReportState(void) {
                     Position->GetDistanceAGL() );
   cout << out;
   snprintf(out,80, "    Angle of Attack: %6.2f deg  Pitch Angle: %6.2f deg\n",
-                    GetParameter(FG_ALPHA)*RADTODEG,
-                    Rotation->Gettht()*RADTODEG );
+                    GetParameter(FG_ALPHA)*radtodeg,
+                    Rotation->Gettht()*radtodeg );
   cout << out;
   snprintf(out,80, "    Flight Path Angle: %6.2f deg  Climb Rate: %5.0f ft/min\n",
-                    Position->GetGamma()*RADTODEG,
+                    Position->GetGamma()*radtodeg,
                     Position->Gethdot()*60 );
   cout << out;                  
   snprintf(out,80, "    Normal Load Factor: %4.2f g's  Pitch Rate: %5.2f deg/s\n",
                     Aerodynamics->GetNlf(),
-                    GetParameter(FG_PITCHRATE)*RADTODEG );
+                    GetParameter(FG_PITCHRATE)*radtodeg );
   cout << out;
   snprintf(out,80, "    Heading: %3.0f deg true  Sideslip: %5.2f deg\n",
-                    Rotation->Getpsi()*RADTODEG,
-                    GetParameter(FG_BETA)*RADTODEG );                  
+                    Rotation->Getpsi()*radtodeg,
+                    GetParameter(FG_BETA)*radtodeg );                  
   cout << out;
   snprintf(out,80, "    Bank Angle: %5.2f deg\n",
-                    Rotation->Getphi()*RADTODEG );
+                    Rotation->Getphi()*radtodeg );
   cout << out;
   snprintf(out,80, "    Elevator: %5.2f deg  Left Aileron: %5.2f deg  Rudder: %5.2f deg\n",
-                    GetParameter(FG_ELEVATOR_POS)*RADTODEG,
-                    GetParameter(FG_AILERON_POS)*RADTODEG,
-                    GetParameter(FG_RUDDER_POS)*RADTODEG );
+                    GetParameter(FG_ELEVATOR_POS)*radtodeg,
+                    GetParameter(FG_AILERON_POS)*radtodeg,
+                    GetParameter(FG_RUDDER_POS)*radtodeg );
   cout << out;                  
   snprintf(out,80, "    Throttle: %5.2f%c\n",
                     FCS->GetThrottlePos(0)*100,'%' );
   cout << out;
   
   snprintf(out,80, "    Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
-                    FDMExec->GetAuxiliary()->GetHeadWind()*jsbFPSTOKTS,
-                    FDMExec->GetAuxiliary()->GetCrossWind()*jsbFPSTOKTS );
+                    FDMExec->GetAuxiliary()->GetHeadWind()*fpstokts,
+                    FDMExec->GetAuxiliary()->GetCrossWind()*fpstokts );
   cout << out; 
   
   snprintf(out,80, "    Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
-                    Position->GetVground()*jsbFPSTOKTS,
-                    Position->GetGroundTrack()*RADTODEG );
+                    Position->GetVground()*fpstokts,
+                    Position->GetGroundTrack()*radtodeg );
   cout << out;                                   
 
 } 
diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h
index c9ab9d48c..240eeb00d 100644
--- a/src/FDM/JSBSim/FGState.h
+++ b/src/FDM/JSBSim/FGState.h
@@ -58,7 +58,6 @@ INCLUDES
 
 #include <string>
 #include <map>
-#include "FGDefs.h"
 #include "FGJSBBase.h"
 #include "FGInitialCondition.h"
 #include "FGMatrix33.h"
@@ -187,14 +186,14 @@ public:
   inline void Resume(void)  {dt = saved_dt;}
 
   /** Retrieves a parameter.
-      The parameters that can be retrieved are enumerated in FGDefs.h.
+      The parameters that can be retrieved are enumerated in FGJSBBase.h.
       @param val_idx one of the enumerated JSBSim parameters.
       @return the value of the parameter.
       */
   float GetParameter(eParam val_idx);
 
   /** Retrieves a parameter.
-      The parameters that can be retrieved are enumerated in FGDefs.h.
+      The parameters that can be retrieved are enumerated in FGJSBBase.h.
       @param val_string a string representing one of the enumerated JSBSim parameters,
              i.e. "FG_QBAR".
       @return the value of the parameter.
diff --git a/src/FDM/JSBSim/FGTank.cpp b/src/FDM/JSBSim/FGTank.cpp
index 3cfbb0da1..a8f29c1b5 100644
--- a/src/FDM/JSBSim/FGTank.cpp
+++ b/src/FDM/JSBSim/FGTank.cpp
@@ -36,7 +36,6 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGDefs.h"
 #include "FGTank.h"
 
 static const char *IdSrc = "$Id$";
diff --git a/src/FDM/JSBSim/FGTrim.cpp b/src/FDM/JSBSim/FGTrim.cpp
index 1d7fb0c28..ccde8c519 100644
--- a/src/FDM/JSBSim/FGTrim.cpp
+++ b/src/FDM/JSBSim/FGTrim.cpp
@@ -158,76 +158,6 @@ void FGTrim::Report(void) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGTrim::ReportState(void) {
-  char out[80], flap[10], gear[10];
-  
-  cout << endl << "  JSBSim State" << endl;
-  snprintf(out,80,"    Weight: %7.0f lbs.  CG: %5.1f, %5.1f, %5.1f inches\n",
-                   fdmex->GetMassBalance()->GetWeight(),
-                   fdmex->GetMassBalance()->GetXYZcg(1),
-                   fdmex->GetMassBalance()->GetXYZcg(2),
-                   fdmex->GetMassBalance()->GetXYZcg(3));
-  cout << out;             
-  if( fdmex->GetFCS()->GetDfPos() <= 0.01)
-    snprintf(flap,10,"Up");
-  else
-    snprintf(flap,10,"%2.0f",fdmex->GetFCS()->GetDfPos());
-  if(fdmex->GetGroundReactions()->GetGearUp() == true)
-    snprintf(gear,10,"Up");
-  else
-    snprintf(gear,10,"Down");
-  snprintf(out,80, "    Flaps: %3s  Gear: %4s\n",flap,gear);
-  cout << out;
-  snprintf(out,80, "    Speed: %4.0f KCAS  Mach: %5.2f\n",
-                    fdmex->GetAuxiliary()->GetVcalibratedKTS(),
-                    fdmex->GetState()->GetParameter(FG_MACH) );
-  cout << out;
-  snprintf(out,80, "    Altitude: %7.0f ft.  AGL Altitude: %7.0f ft.\n",
-                    fdmex->GetPosition()->Geth(),
-                    fdmex->GetPosition()->GetDistanceAGL() );
-  cout << out;
-  snprintf(out,80, "    Angle of Attack: %6.2f deg  Pitch Angle: %6.2f deg\n",
-                    fdmex->GetState()->GetParameter(FG_ALPHA)*RADTODEG,
-                    fdmex->GetRotation()->Gettht()*RADTODEG );
-  cout << out;
-  snprintf(out,80, "    Flight Path Angle: %6.2f deg  Climb Rate: %5.0f ft/min\n",
-                    fdmex->GetPosition()->GetGamma()*RADTODEG,
-                    fdmex->GetPosition()->Gethdot()*60 );
-  cout << out;                  
-  snprintf(out,80, "    Normal Load Factor: %4.2f g's  Pitch Rate: %5.2f deg/s\n",
-                    fdmex->GetAerodynamics()->GetNlf(),
-                    fdmex->GetState()->GetParameter(FG_PITCHRATE)*RADTODEG );
-  cout << out;
-  snprintf(out,80, "    Heading: %3.0f deg true  Sideslip: %5.2f deg\n",
-                    fdmex->GetRotation()->Getpsi()*RADTODEG,
-                    fdmex->GetState()->GetParameter(FG_BETA)*RADTODEG );                  
-  cout << out;
-  snprintf(out,80, "    Bank Angle: %5.2f deg\n",
-                    fdmex->GetRotation()->Getphi()*RADTODEG );
-  cout << out;
-  snprintf(out,80, "    Elevator: %5.2f deg  Left Aileron: %5.2f deg  Rudder: %5.2f deg\n",
-                    fdmex->GetState()->GetParameter(FG_ELEVATOR_POS)*RADTODEG,
-                    fdmex->GetState()->GetParameter(FG_AILERON_POS)*RADTODEG,
-                    fdmex->GetState()->GetParameter(FG_RUDDER_POS)*RADTODEG );
-  cout << out;                  
-  snprintf(out,80, "    Throttle: %5.2f%c\n",
-                    fdmex->GetFCS()->GetThrottlePos(0),'%' );
-  cout << out;
-  
-  snprintf(out,80, "    Wind Components: %5.2f kts head wind, %5.2f kts cross wind\n",
-                    fdmex->GetAuxiliary()->GetHeadWind()*jsbFPSTOKTS,
-                    fdmex->GetAuxiliary()->GetCrossWind()*jsbFPSTOKTS );
-  cout << out; 
-  
-  snprintf(out,80, "    Ground Speed: %4.0f knots , Ground Track: %3.0f deg true\n",
-                    fdmex->GetPosition()->GetVground()*jsbFPSTOKTS,
-                    fdmex->GetPosition()->GetGroundTrack()*RADTODEG );
-  cout << out;                                   
-
-}                  
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 void FGTrim::ClearStates(void) {
     FGTrimAxis* ta;
     
@@ -317,7 +247,6 @@ bool FGTrim::EditState( State state, Control new_control ){
       }
       iAxes++;
   }
-  cout << "Exit FGTrim::EditState(...)" << endl;
   return result;
 }  
        
@@ -452,12 +381,11 @@ bool FGTrim::solve(void) {
       x1=xhi;f1=ahi;
       x3=xlo;f3=alo;
     }   */
-
     d0=fabs(x3-x1);
     //iterations
     //max_sub_iterations=TrimAxes[current_axis]->GetIterationLimit();
-    while (!TrimAxes[current_axis]->InTolerance() && (fabs(d) > eps) 
-              && (Nsub < max_sub_iterations)) {
+    while ( (TrimAxes[current_axis]->InTolerance() == false )
+             && (fabs(d) > eps) && (Nsub < max_sub_iterations)) {
       Nsub++;
       d=(x3-x1)/d0;
       x2=x1-d*d0*f1/(f3-f1);
diff --git a/src/FDM/JSBSim/FGTrim.h b/src/FDM/JSBSim/FGTrim.h
index 5603bed11..bdd3316be 100644
--- a/src/FDM/JSBSim/FGTrim.h
+++ b/src/FDM/JSBSim/FGTrim.h
@@ -199,11 +199,6 @@ public:
   */     
   void Report(void);
   
-  /** Prints a summary of simulator state (speed, altitude, 
-      configuration, etc.)
-  */
-  void ReportState(void);
-  
   /** Iteration statistics
   */
   void TrimStats();
diff --git a/src/FDM/JSBSim/FGTrimAxis.cpp b/src/FDM/JSBSim/FGTrimAxis.cpp
index d59977b0b..594fe1412 100644
--- a/src/FDM/JSBSim/FGTrimAxis.cpp
+++ b/src/FDM/JSBSim/FGTrimAxis.cpp
@@ -54,7 +54,6 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
   fgic=ic;
   state=st;
   control=ctrl;
-  solver_eps=tolerance;
   max_iterations=10;
   control_value=0;
   its_to_stable_value=0;
@@ -63,6 +62,17 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
   state_convert=1.0;
   control_convert=1.0;
   state_value=0;
+    switch(state) {
+    case tUdot: tolerance = DEFAULT_TOLERANCE; break;
+    case tVdot: tolerance = DEFAULT_TOLERANCE; break;
+    case tWdot: tolerance = DEFAULT_TOLERANCE; break;
+    case tQdot: tolerance = DEFAULT_TOLERANCE / 10; break;
+    case tPdot: tolerance = DEFAULT_TOLERANCE / 10; break;
+    case tRdot: tolerance = DEFAULT_TOLERANCE / 10; break;
+    case tHmgt: tolerance = 0.01; break;
+  }  
+  
+  solver_eps=tolerance;
   switch(control) {
   case tThrottle:
     control_min=0;
@@ -70,19 +80,19 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
     control_value=0.5;
     break;
   case tBeta:
-    control_min=-30*DEGTORAD;
-    control_max=30*DEGTORAD;
-    control_convert=RADTODEG;
+    control_min=-30*degtorad;
+    control_max=30*degtorad;
+    control_convert=radtodeg;
     break;
   case tAlpha:
     control_min=fdmex->GetAircraft()->GetAlphaCLMin();
     control_max=fdmex->GetAircraft()->GetAlphaCLMax();
     if(control_max <= control_min) {
-      control_max=20*DEGTORAD;
-      control_min=-5*DEGTORAD;
+      control_max=20*degtorad;
+      control_min=-5*degtorad;
     }
     control_value= (control_min+control_max)/2;
-    control_convert=RADTODEG;
+    control_convert=radtodeg;
     solver_eps=tolerance/100;
     break;
   case tPitchTrim:
@@ -93,7 +103,7 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
   case tRudder:
     control_min=-1;
     control_max=1;
-    state_convert=RADTODEG;
+    state_convert=radtodeg;
     solver_eps=tolerance/100;
     break;
   case tAltAGL:
@@ -103,38 +113,29 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
     solver_eps=tolerance/100;
     break;
   case tTheta:
-    control_min=fdmex->GetRotation()->Gettht() - 5*DEGTORAD;
-    control_max=fdmex->GetRotation()->Gettht() + 5*DEGTORAD;
-    state_convert=RADTODEG;
+    control_min=fdmex->GetRotation()->Gettht() - 5*degtorad;
+    control_max=fdmex->GetRotation()->Gettht() + 5*degtorad;
+    state_convert=radtodeg;
     break;
   case tPhi:
-    control_min=fdmex->GetRotation()->Getphi() - 30*DEGTORAD;
-    control_max=fdmex->GetRotation()->Getphi() + 30*DEGTORAD;
-    state_convert=RADTODEG;
-    control_convert=RADTODEG;
+    control_min=fdmex->GetRotation()->Getphi() - 30*degtorad;
+    control_max=fdmex->GetRotation()->Getphi() + 30*degtorad;
+    state_convert=radtodeg;
+    control_convert=radtodeg;
     break;
   case tGamma:
     solver_eps=tolerance/100;
-    control_min=-80*DEGTORAD;
-    control_max=80*DEGTORAD;
-    control_convert=RADTODEG;
+    control_min=-80*degtorad;
+    control_max=80*degtorad;
+    control_convert=radtodeg;
     break;
   case tHeading:
-    control_min=fdmex->GetRotation()->Getpsi() - 30*DEGTORAD;
-    control_max=fdmex->GetRotation()->Getpsi() + 30*DEGTORAD;
-    state_convert=RADTODEG;
+    control_min=fdmex->GetRotation()->Getpsi() - 30*degtorad;
+    control_max=fdmex->GetRotation()->Getpsi() + 30*degtorad;
+    state_convert=radtodeg;
     break;
   }
   
-  switch(state) {
-    case tUdot: tolerance = DEFAULT_TOLERANCE; break;
-    case tVdot: tolerance = DEFAULT_TOLERANCE; break;
-    case tWdot: tolerance = DEFAULT_TOLERANCE; break;
-    case tQdot: tolerance = DEFAULT_TOLERANCE / 10; break;
-    case tPdot: tolerance = DEFAULT_TOLERANCE / 10; break;
-    case tRdot: tolerance = DEFAULT_TOLERANCE / 10; break;
-    case tHmgt: tolerance = 0.01; break;
-  }  
   
   if (debug_lvl & 2) cout << "Instantiated: FGTrimAxis" << endl;
 }
@@ -324,9 +325,9 @@ bool FGTrimAxis::initTheta(void) {
 	i++;   
   }	    	    	
   //cout << i << endl;
-  cout << "    Initial Theta: " << fdmex->GetRotation()->Gettht()*RADTODEG << endl;
-  control_min=(theta+5)*DEGTORAD;
-  control_max=(theta-5)*DEGTORAD;
+  cout << "    Initial Theta: " << fdmex->GetRotation()->Gettht()*radtodeg << endl;
+  control_min=(theta+5)*degtorad;
+  control_max=(theta-5)*degtorad;
   fgic->SetAltitudeAGLFtIC(saveAlt);
   if(i < 100) 
     return true;
diff --git a/src/FDM/JSBSim/JSBSim.cpp b/src/FDM/JSBSim/JSBSim.cpp
index 366d394b1..499e95167 100644
--- a/src/FDM/JSBSim/JSBSim.cpp
+++ b/src/FDM/JSBSim/JSBSim.cpp
@@ -148,11 +148,35 @@ int main(int argc, char** argv)
     	cerr << "Aircraft file " << argv[1] << " was not found" << endl;
 	    exit(-1);
     }
-    if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2])))
-                   FDMExec->GetState()->Initialize(2000,0,0,0,0,0,0.5,0.5,40000, 0, 0, 0);
+    if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2]))) {
+    	cerr << "JSBSim could not be started" << endl;
+	    exit(-1);
+    }                   
   }
 
-  while (FDMExec->Run()) {}
+  struct FGJSBBase::Message* msg;
+  while (FDMExec->Run()) {
+    while (FDMExec->ReadMessage()) {
+      msg = FDMExec->ProcessMessage();
+      switch (msg->type) {
+      case FGJSBBase::Message::eText:
+        cout << msg->messageId << ": " << msg->text << endl;
+        break;
+      case FGJSBBase::Message::eBool:
+        cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;
+        break;
+      case FGJSBBase::Message::eInteger:
+        cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;
+        break;
+      case FGJSBBase::Message::eDouble:
+        cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;
+        break;
+      default:
+        cerr << "Unrecognized message type." << endl;
+	      break;
+      }
+    }
+  }
 
   delete FDMExec;
 
diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h
index 6eba5cf18..dda386f7c 100644
--- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h
+++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h
@@ -42,7 +42,6 @@ INCLUDES
 #endif
 
 #include <string>
-#include "../FGDefs.h"
 #include "../FGJSBBase.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx
index 673faaf04..e061e5432 100644
--- a/src/FDM/flight.cxx
+++ b/src/FDM/flight.cxx
@@ -23,6 +23,8 @@
 
 #include <stdio.h>
 
+#include <plib/sg.h>
+
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
@@ -203,7 +205,7 @@ FGInterface::common_init ()
     set_Latitude( fgGetDouble("/position/latitude-deg")
                   * SGD_DEGREES_TO_RADIANS );
     double ground_elev_m = scenery.get_cur_elev();
-    double ground_elev_ft = ground_elev_m * METERS_TO_FEET;
+    double ground_elev_ft = ground_elev_m * SG_METER_TO_FEET;
     if ( fgGetBool("/sim/startup/onground")
          || fgGetDouble("/position/altitude-ft") < ground_elev_ft ) {
         fgSetDouble("/position/altitude-ft", ground_elev_ft);
@@ -461,7 +463,7 @@ void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
     _set_Geodetic_Position( lat_geod, lon, alt );
 	
     _set_Sea_level_radius( sl_radius2 * SG_METER_TO_FEET );
-    _set_Runway_altitude( scenery.get_cur_elev()*METERS_TO_FEET ); 
+    _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET ); 
 	
     _set_sin_lat_geocentric( lat_geoc );
     _set_cos_lat_geocentric( lat_geoc );
diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx
index 498bdf3f0..8df8a559a 100644
--- a/src/Main/fg_io.cxx
+++ b/src/Main/fg_io.cxx
@@ -32,6 +32,7 @@
 #include <simgear/io/sg_file.hxx>
 #include <simgear/io/sg_serial.hxx>
 #include <simgear/io/sg_socket.hxx>
+#include <simgear/io/sg_socket_udp.hxx>
 #include <simgear/math/sg_types.hxx>
 #include <simgear/timing/timestamp.hxx>