From 62a359cc4a338b2f8b720edf8183ab5b69710b14 Mon Sep 17 00:00:00 2001
From: ehofman <ehofman>
Date: Tue, 25 Oct 2005 13:49:55 +0000
Subject: [PATCH] Alex Romosan:

* Use "const string&" rather than "string" in function calls when appropriate.
* Use "const Point3D&" instead of "Pint3D" in function calls when appropriate.
* Improved course calculation in calc_gc_course_dist()
* Safer thread handling code.

Vassilii Khachaturov:

Dont use "const Point3D&" for return types unless you're absolutely sure.

Erik Hofman:

* Use SGD_(2)PI(_[24]) as defined in simgear/constants.h rather than
  calculating it by hand every time.
---
 src/AIModel/AICarrier.cxx            |  4 +-
 src/AIModel/AICarrier.hxx            |  4 +-
 src/AIModel/AIFlightPlan.cxx         |  8 ++--
 src/AIModel/AIFlightPlan.hxx         | 18 ++++----
 src/AIModel/AIFlightPlanCreate.cxx   | 34 +++++++-------
 src/ATC/AIEntity.cxx                 |  5 ++-
 src/ATC/AIEntity.hxx                 |  8 ++--
 src/ATC/AILocalTraffic.cxx           |  8 ++--
 src/ATC/AILocalTraffic.hxx           |  8 ++--
 src/ATC/AIMgr.cxx                    | 10 ++---
 src/ATC/AIMgr.hxx                    |  8 ++--
 src/ATC/AIPlane.cxx                  |  4 +-
 src/ATC/AIPlane.hxx                  |  6 +--
 src/ATC/ATC.cxx                      | 10 ++---
 src/ATC/ATC.hxx                      | 18 ++++----
 src/ATC/ATCDialog.cxx                |  4 +-
 src/ATC/ATCDialog.hxx                |  6 +--
 src/ATC/ATCProjection.cxx            | 14 +++---
 src/ATC/ATCProjection.hxx            | 14 +++---
 src/ATC/ATCVoice.cxx                 |  2 +-
 src/ATC/ATCVoice.hxx                 |  2 +-
 src/ATC/ATCdisplay.cxx               |  6 +--
 src/ATC/ATCdisplay.hxx               |  6 +--
 src/ATC/ATCmgr.cxx                   | 18 ++++----
 src/ATC/ATCmgr.hxx                   | 18 ++++----
 src/ATC/ATCutils.cxx                 |  8 ++--
 src/ATC/ATCutils.hxx                 |  8 ++--
 src/ATC/approach.cxx                 |  9 ++--
 src/ATC/approach.hxx                 |  4 +-
 src/ATC/atis.hxx                     |  4 +-
 src/ATC/commlist.cxx                 |  8 ++--
 src/ATC/commlist.hxx                 |  8 ++--
 src/ATC/ground.cxx                   | 14 +++---
 src/ATC/ground.hxx                   | 16 +++----
 src/ATC/tower.cxx                    | 67 +++++++++++++++-------------
 src/ATC/tower.hxx                    | 57 ++++++++++++-----------
 src/ATC/transmission.hxx             |  6 +--
 src/ATC/transmissionlist.cxx         |  2 +-
 src/ATC/transmissionlist.hxx         |  2 +-
 src/Airports/runways.cxx             |  8 ++--
 src/Airports/runways.hxx             |  8 ++--
 src/Airports/simple.cxx              | 65 +++++++++++++--------------
 src/Airports/simple.hxx              | 57 +++++++++++------------
 src/Autopilot/auto_gui.cxx           |  2 +-
 src/Autopilot/auto_gui.hxx           |  2 +-
 src/Autopilot/route_mgr.hxx          |  2 +-
 src/Autopilot/xmlauto.hxx            |  4 +-
 src/Cockpit/built_in/FGMagRibbon.cxx |  2 +-
 src/Cockpit/hud.hxx                  | 18 ++++----
 src/Cockpit/hud_ladr.cxx             |  8 ++--
 src/Cockpit/hud_rwy.cxx              |  6 +--
 src/Cockpit/panel.cxx                |  2 +-
 src/Cockpit/panel.hxx                |  5 +--
 src/Environment/environment.cxx      |  2 +-
 src/Environment/environment_ctrl.cxx |  4 +-
 src/Environment/environment_ctrl.hxx |  4 +-
 src/Environment/fgclouds.cxx         | 10 ++---
 src/Environment/fgclouds.hxx         |  8 ++--
 src/Instrumentation/kr_87.hxx        |  2 +-
 src/Instrumentation/tacan.cxx        |  2 +-
 src/Instrumentation/tacan.hxx        |  2 +-
 src/Main/metar_main.cxx              |  6 ++-
 src/Navaids/fix.hxx                  |  2 +-
 src/Navaids/nav.hxx                  |  8 ++--
 src/Navaids/navlist.cxx              |  2 +-
 src/Navaids/navlist.hxx              |  4 +-
 src/Network/ray.cxx                  | 18 ++++----
 src/Scenery/scenery.cxx              |  4 +-
 src/Scenery/scenery.hxx              | 10 ++---
 src/Scenery/tileentry.hxx            | 10 ++---
 src/Server/messagebuf.cxx            |  2 +-
 src/Server/messagebuf.hxx            | 12 ++---
 src/Sound/morse.cxx                  |  6 +--
 src/Systems/electrical.hxx           |  4 +-
 src/Time/light.cxx                   |  3 --
 src/Time/light.hxx                   |  8 ++--
 src/Traffic/SchedFlight.cxx          | 16 +++----
 src/Traffic/SchedFlight.hxx          | 18 ++++----
 src/Traffic/Schedule.hxx             | 10 ++---
 79 files changed, 414 insertions(+), 408 deletions(-)

diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx
index 742b026b8..525592c74 100644
--- a/src/AIModel/AICarrier.cxx
+++ b/src/AIModel/AICarrier.cxx
@@ -101,7 +101,7 @@ void FGAICarrier::setFlolsOffset(const Point3D& off) {
   flols_off = off;
 }
 
-void FGAICarrier::getVelocityWrtEarth(sgdVec3 v, sgdVec3 omega, sgdVec3 pivot) {
+void FGAICarrier::getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot) {
   sgdCopyVec3(v, vel_wrt_earth );
   sgdCopyVec3(omega, rot_wrt_earth );
   sgdCopyVec3(pivot, rot_pivot_wrt_earth );
@@ -534,7 +534,7 @@ bool FGAICarrier::mark_cat(ssgEntity* e, const list<string>& cat_objects, bool m
   return found;
 }
 
-void FGAICarrier::UpdateFlols(sgdMat3 trans) {
+void FGAICarrier::UpdateFlols(const sgdMat3& trans) {
     
     float in[3];
     float out[3];
diff --git a/src/AIModel/AICarrier.hxx b/src/AIModel/AICarrier.hxx
index 24802c55d..be82c8c8f 100644
--- a/src/AIModel/AICarrier.hxx
+++ b/src/AIModel/AICarrier.hxx
@@ -87,10 +87,10 @@ public:
         void setFlolsOffset(const Point3D& off);
         void setTACANChannelID(const string &);
 
-	void getVelocityWrtEarth(sgdVec3 v, sgdVec3 omega, sgdVec3 pivot);
+	void getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot);
 	virtual void bind();
     virtual void unbind();
-    void UpdateFlols ( sgdMat3 trans );
+    void UpdateFlols ( const sgdMat3& trans );
     void UpdateWind ( double dt );
     void UpdateTACAN( double dt );
     void setWind_from_east( double fps );
diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx
index 025f03e21..39ca074d8 100644
--- a/src/AIModel/AIFlightPlan.cxx
+++ b/src/AIModel/AIFlightPlan.cxx
@@ -41,7 +41,7 @@
 #include "AIFlightPlan.hxx"
 
 
-FGAIFlightPlan::FGAIFlightPlan(string filename)
+FGAIFlightPlan::FGAIFlightPlan(const string& filename)
 {
   int i;
   start_time = 0;
@@ -100,9 +100,9 @@ FGAIFlightPlan::FGAIFlightPlan(FGAIModelEntity *entity,
 			       FGAirport *arr,
 			       bool firstLeg,
 			       double radius,
-			       string fltType,
-			       string acType,
-			       string airline)
+			       const string& fltType,
+			       const string& acType,
+			       const string& airline)
 {
   leg = 10;
   gateId=0;
diff --git a/src/AIModel/AIFlightPlan.hxx b/src/AIModel/AIFlightPlan.hxx
index 15c479672..3c6ed9bca 100644
--- a/src/AIModel/AIFlightPlan.hxx
+++ b/src/AIModel/AIFlightPlan.hxx
@@ -49,7 +49,7 @@ public:
    bool on_ground;
   } waypoint;
 
-   FGAIFlightPlan(string filename);
+   FGAIFlightPlan(const string& filename);
   FGAIFlightPlan(FGAIModelEntity *entity,
 		 double course,
 		 time_t start,
@@ -57,9 +57,9 @@ public:
 		 FGAirport *arr,
 		 bool firstLeg,
 		 double radius,
-		 string fltType,
-		 string acType,
-		 string airline);
+		 const string& fltType,
+		 const string& acType,
+		 const string& airline);
    ~FGAIFlightPlan();
 
    waypoint* getPreviousWaypoint( void );
@@ -77,14 +77,14 @@ public:
   time_t getStartTime() { return start_time; }; 
 
   void    create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
-		 bool firstLeg, double radius, string fltType, string aircraftType, string airline);
+		 bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
 
   void setLeg(int val) { leg = val;};
   void setTime(time_t st) { start_time = st; };
   int getGate() { return gateId; };
   double getLeadInAngle() { return leadInAngle; };
-  string getRunway() { return rwy._rwy_no; };
-  string getRunwayId() { return rwy._id; };
+  const string& getRunway() { return rwy._rwy_no; };
+  const string& getRunwayId() { return rwy._id; };
   void setRepeat(bool r) { repeat = r; };
   bool getRepeat(void) { return repeat; };
   void restart(void);
@@ -106,8 +106,8 @@ private:
   int gateId;
   string activeRunway;
 
-  void createPushBack(bool, FGAirport*, double, double, double, string, string, string);
-  void createTaxi(bool, int, FGAirport *, double, double, double, string, string, string);
+  void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
+  void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
   void createTakeOff(bool, FGAirport *, double);
   void createClimb(bool, FGAirport *, double, double);
   void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double);
diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx
index c851a6e71..5c0aa56e3 100644
--- a/src/AIModel/AIFlightPlanCreate.cxx
+++ b/src/AIModel/AIFlightPlanCreate.cxx
@@ -38,7 +38,7 @@
 // Check lat/lon values during initialization;
 void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr, double alt, double speed, 
 			    double latitude, double longitude, bool firstFlight,
-			    double radius, string fltType, string aircraftType, string airline)
+			    double radius, const string& fltType, const string& aircraftType, const string& airline)
 { 
   int currWpt = wpt_iterator - waypoints.begin();
   switch(legNr)
@@ -96,9 +96,9 @@ void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
 				    double latitude,
 				    double longitude,
 				    double radius,
-				    string fltType,
-				    string aircraftType,
-				    string airline)
+				    const string& fltType,
+				    const string& aircraftType,
+				    const string& airline)
 {
   double heading;
   double lat;
@@ -183,7 +183,7 @@ void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
  * createCreate Taxi. 
  * initialize the Aircraft at the parking location
  ******************************************************************/
-void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt, double latitude, double longitude, double radius, string fltType, string acType, string airline)
+void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt, double latitude, double longitude, double radius, const string& fltType, const string& acType, const string& airline)
 {
   double wind_speed;
   double wind_heading;
@@ -204,7 +204,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt,
       // "NOTE: this is currently fixed to "com" for commercial traffic
       // Should be changed to be used dynamically to allow "gen" and "mil"
       // as well
-      apt->getActiveRunway("com", 1, &activeRunway);
+      apt->getActiveRunway("com", 1, activeRunway);
       if (!(globals->get_runways()->search(apt->getId(), 
 					    activeRunway, 
 					    &rwy)))
@@ -214,7 +214,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt,
 	  exit(1);
 	}
       //string test;
-      //apt->getActiveRunway(string("com"), 1, &test);
+      //apt->getActiveRunway(string("com"), 1, test);
       //exit(1);
       
       heading = rwy._heading;
@@ -335,7 +335,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt,
       // "NOTE: this is currently fixed to "com" for commercial traffic
       // Should be changed to be used dynamically to allow "gen" and "mil"
       // as well
-      //apt->getActiveRunway("com", 1, &name);
+      //apt->getActiveRunway("com", 1, name);
       //if (!(globals->get_runways()->search(apt->getId(), 
       //				    name, 
       //			    &rwy)))
@@ -345,7 +345,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt,
       // exit(1);
       //	}
       //string test;
-      //apt->getActiveRunway(string("com"), 1, &test);
+      //apt->getActiveRunway(string("com"), 1, test);
       //exit(1);
       
       //heading = rwy._heading;
@@ -514,7 +514,7 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
        // "NOTE: this is currently fixed to "com" for commercial traffic
       // Should be changed to be used dynamically to allow "gen" and "mil"
       // as well
-      apt->getActiveRunway("com", 1, &activeRunway);
+      apt->getActiveRunway("com", 1, activeRunway);
 	if (!(globals->get_runways()->search(apt->getId(), 
 					      activeRunway, 
 					      &rwy)))
@@ -524,7 +524,7 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
 	    exit(1);
 	  }
 	//string test;
-      //apt->getActiveRunway(string("com"), 1, &test);
+      //apt->getActiveRunway(string("com"), 1, test);
       //exit(1);
     }
   
@@ -609,7 +609,7 @@ void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed,
       // "NOTE: this is currently fixed to "com" for commercial traffic
       // Should be changed to be used dynamically to allow "gen" and "mil"
       // as well
-      apt->getActiveRunway("com", 1, &activeRunway);
+      apt->getActiveRunway("com", 1, activeRunway);
 	if (!(globals->get_runways()->search(apt->getId(), 
 					      activeRunway, 
 					      &rwy)))
@@ -619,7 +619,7 @@ void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed,
 	    exit(1);
 	  }
 	//string test;
-	//apt->getActiveRunway(string("com"), 1, &test);
+	//apt->getActiveRunway(string("com"), 1, test);
       //exit(1);
     }
   
@@ -708,7 +708,7 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep, FGAirport *a
  
   //string name;
   // should be changed dynamically to allow "gen" and "mil"
-  arr->getActiveRunway("com", 2, &activeRunway);
+  arr->getActiveRunway("com", 2, activeRunway);
   if (!(globals->get_runways()->search(arr->getId(), 
 				       activeRunway, 
 				       &rwy)))
@@ -718,7 +718,7 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep, FGAirport *a
       exit(1);
     }
   //string test;
-  //arr->getActiveRunway(string("com"), 1, &test);
+  //arr->getActiveRunway(string("com"), 1, test);
   //exit(1);
   
   //cerr << "Altitude = " << alt << endl;
@@ -787,7 +787,7 @@ void FGAIFlightPlan::createDecent(FGAirport *apt)
   //Beginning of Decent
   //string name;
   // allow "mil" and "gen" as well
-  apt->getActiveRunway("com", 2, &activeRunway);
+  apt->getActiveRunway("com", 2, activeRunway);
     if (!(globals->get_runways()->search(apt->getId(), 
 					  activeRunway, 
 					  &rwy)))
@@ -797,7 +797,7 @@ void FGAIFlightPlan::createDecent(FGAirport *apt)
 	exit(1);
       }
     //string test;
-    //apt->getActiveRunway(string("com"), 1, &test);
+    //apt->getActiveRunway(string("com"), 1, test);
   //exit(1);
 
   //cerr << "Done" << endl;
diff --git a/src/ATC/AIEntity.cxx b/src/ATC/AIEntity.cxx
index 945668a15..efcaaee1c 100644
--- a/src/ATC/AIEntity.cxx
+++ b/src/ATC/AIEntity.cxx
@@ -68,8 +68,9 @@ void FGAIEntity::SetModel(ssgBranch* model) {
 void FGAIEntity::Update(double dt) {
 }
 
-string FGAIEntity::GetCallsign() {
-	return("");
+const string &FGAIEntity::GetCallsign() {
+	static string s = "";
+	return(s);
 }
 
 void FGAIEntity::RegisterTransmission(int code) {
diff --git a/src/ATC/AIEntity.hxx b/src/ATC/AIEntity.hxx
index 0cf5e52ca..43da25d53 100644
--- a/src/ATC/AIEntity.hxx
+++ b/src/ATC/AIEntity.hxx
@@ -47,15 +47,15 @@ public:
 	void SetModel(ssgBranch* model);
 
     // Run the internal calculations
-    virtual void Update(double dt);
+    virtual void Update(double dt)=0;
 	
     // Send a transmission *TO* the AIEntity.
     // FIXME int code is a hack - eventually this will receive Alexander's coded messages.
-    virtual void RegisterTransmission(int code);
+    virtual void RegisterTransmission(int code)=0;
 	
-	inline Point3D GetPos() { return(_pos); }
+	inline const Point3D& GetPos() const { return(_pos); }
 	
-	virtual string GetCallsign();
+	virtual const string& GetCallsign()=0;
 	
 protected:
 
diff --git a/src/ATC/AILocalTraffic.cxx b/src/ATC/AILocalTraffic.cxx
index fe716d904..c8caac821 100644
--- a/src/ATC/AILocalTraffic.cxx
+++ b/src/ATC/AILocalTraffic.cxx
@@ -128,7 +128,7 @@ FGAILocalTraffic::~FGAILocalTraffic() {
 	//_model->deRef();
 }
 
-void FGAILocalTraffic::GetAirportDetails(string id) {
+void FGAILocalTraffic::GetAirportDetails(const string& id) {
 	AirportATC a;
 	if(ATC->GetAirportATCDetails(airportID, &a)) {
 		if(a.tower_freq) {	// Has a tower - TODO - check the opening hours!!!
@@ -164,7 +164,7 @@ void FGAILocalTraffic::GetAirportDetails(string id) {
 
 // Get details of the active runway
 // It is assumed that by the time this is called the tower control and airport code will have been set up.
-void FGAILocalTraffic::GetRwyDetails(string id) {
+void FGAILocalTraffic::GetRwyDetails(const string& id) {
 	//cout << "GetRwyDetails called" << endl;
 	
 	if(_controlled) {
@@ -226,7 +226,7 @@ To a certain extent it's FGAIMgr that has to worry about this, but we need to pr
 sufficient initialisation functionality within the plane classes to allow the manager
 to initially position them where and how required.
 */
-bool FGAILocalTraffic::Init(const string& callsign, string ICAO, OperatingState initialState, PatternLeg initialLeg) {
+bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, OperatingState initialState, PatternLeg initialLeg) {
 	//cout << "FGAILocalTraffic.Init(...) called" << endl;
 	airportID = ICAO;
 	
@@ -1314,7 +1314,7 @@ void FGAILocalTraffic::ProcessCallback(int code) {
 	}
 }
 
-void FGAILocalTraffic::ExitRunway(Point3D orthopos) {
+void FGAILocalTraffic::ExitRunway(const Point3D& orthopos) {
 	//cout << "In ExitRunway" << endl;
 	//cout << "Runway ID is " << rwy.ID << endl;
 	
diff --git a/src/ATC/AILocalTraffic.hxx b/src/ATC/AILocalTraffic.hxx
index 808739f3a..2bd321d81 100644
--- a/src/ATC/AILocalTraffic.hxx
+++ b/src/ATC/AILocalTraffic.hxx
@@ -62,7 +62,7 @@ public:
 	~FGAILocalTraffic();
 	
 	// Initialise
-	bool Init(const string& callsign, string ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
+	bool Init(const string& callsign, const string& ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
 	
 	// Run the internal calculations
 	void Update(double dt);
@@ -119,9 +119,9 @@ protected:
 	FGATCAlignedProjection ortho;	// Orthogonal mapping of the local area with the threshold at the origin
 	// and the runway aligned with the y axis.
 	
-	void GetAirportDetails(string id);
+	void GetAirportDetails(const string& id);
 	
-	void GetRwyDetails(string id);
+	void GetRwyDetails(const string& id);
 	
 	double responseCounter;		// timer in seconds to allow response to requests to be a little while after them
 	// Will almost certainly get moved to FGAIPlane.	
@@ -213,7 +213,7 @@ private:
 
 	void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
 
-	void ExitRunway(Point3D orthopos);
+	void ExitRunway(const Point3D& orthopos);
 
 	void StartTaxi();
 
diff --git a/src/ATC/AIMgr.cxx b/src/ATC/AIMgr.cxx
index c7c7c4744..22cb4716a 100644
--- a/src/ATC/AIMgr.cxx
+++ b/src/ATC/AIMgr.cxx
@@ -298,13 +298,13 @@ void FGAIMgr::update(double dt) {
 	//cout << "Size of AI list is " << ai_list.size() << '\n';
 }
 
-void FGAIMgr::ScheduleRemoval(string s) {
+void FGAIMgr::ScheduleRemoval(const string& s) {
 	//cout << "Scheduling removal of plane " << s << " from AIMgr\n";
 	removalList.push_back(s);
 }
 
 // Activate AI traffic at an airport
-void FGAIMgr::ActivateAirport(string ident) {
+void FGAIMgr::ActivateAirport(const string& ident) {
 	ATC->AIRegisterAirport(ident);
 	// TODO - need to start the traffic more randomly
 	FGAILocalTraffic* local_traffic = new FGAILocalTraffic;
@@ -319,7 +319,7 @@ void FGAIMgr::ActivateAirport(string ident) {
 }
 
 // Hack - Generate AI traffic at an airport with no facilities file
-void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
+void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist) {
 	// Ugly hack - don't let VFR Cessnas operate at a hardwired list of major airports
 	// This will go eventually once airport .xml files specify the traffic profile
 	if(ident == "KSFO" || ident == "KDFW" || ident == "EGLL" || ident == "KORD" || ident == "KJFK" 
@@ -481,7 +481,7 @@ void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
 
 /*
 // Generate a VFR arrival at airport apt, at least distance d (meters) out.
-void FGAIMgr::GenerateVFRArrival(string apt, double d) {
+void FGAIMgr::GenerateVFRArrival(const string& apt, double d) {
 }
 */
 
@@ -608,7 +608,7 @@ string FGAIMgr::GenerateUniqueCallsign() {
 }
 
 // This will be moved somewhere else eventually!!!!
-string FGAIMgr::GenerateShortForm(string callsign, string plane_str, bool local) {
+string FGAIMgr::GenerateShortForm(const string& callsign, const string& plane_str, bool local) {
 	//cout << callsign << '\n';
 	string s;
 	if(local) s = "Trainer-";
diff --git a/src/ATC/AIMgr.hxx b/src/ATC/AIMgr.hxx
index f34cdc151..885536dd5 100644
--- a/src/ATC/AIMgr.hxx
+++ b/src/ATC/AIMgr.hxx
@@ -105,7 +105,7 @@ public:
 	
 	// Signal that it is OK to remove a plane of callsign s
 	// (To be called by the plane itself).
-	void ScheduleRemoval(string s);
+	void ScheduleRemoval(const string& s);
 
 private:
 	
@@ -118,10 +118,10 @@ private:
     //void RemoveFromList(const char* id, atc_type tp);
 	
 	// Activate AI traffic at an airport
-	void ActivateAirport(string ident);
+	void ActivateAirport(const string& ident);
 	
 	// Hack - Generate AI traffic at an airport with no facilities file, with the first plane being at least min_dist out.
-	void GenerateSimpleAirportTraffic(string ident, double min_dist = 0.0);
+	void GenerateSimpleAirportTraffic(const string& ident, double min_dist = 0.0);
 	
 	// Search for valid airports in the vicinity of the user and activate them if necessary
 	void SearchByPos(double range);
@@ -130,7 +130,7 @@ private:
 	
 	string GenerateUniqueCallsign();
 	
-	string GenerateShortForm(string callsign, string plane_str = "Cessna-", bool local = false);
+	string GenerateShortForm(const string& callsign, const string& plane_str = "Cessna-", bool local = false);
 	
 	// TODO - implement a proper robust system for registering and loading AI GA aircraft models
 	bool _havePiperModel;
diff --git a/src/ATC/AIPlane.cxx b/src/ATC/AIPlane.cxx
index 6191558b4..8d501910d 100644
--- a/src/ATC/AIPlane.cxx
+++ b/src/ATC/AIPlane.cxx
@@ -181,7 +181,7 @@ void FGAIPlane::ProcessCallback(int code) {
 // Outputs the transmission either on screen or as audio depending on user preference
 // The refname is a string to identify this sample to the sound manager
 // The repeating flag indicates whether the message should be repeated continuously or played once.
-void FGAIPlane::Render(string refname, bool repeating) {
+void FGAIPlane::Render(const string& refname, bool repeating) {
 #ifdef ENABLE_AUDIO_SUPPORT
 	voice = (voiceOK && fgGetBool("/sim/sound/voice"));
 	if(voice) {
@@ -216,7 +216,7 @@ void FGAIPlane::Render(string refname, bool repeating) {
 
 
 // Cease rendering a transmission.
-void FGAIPlane::NoRender(string refname) {
+void FGAIPlane::NoRender(const string& refname) {
 	if(playing) {
 		if(voice) {
 #ifdef ENABLE_AUDIO_SUPPORT		
diff --git a/src/ATC/AIPlane.hxx b/src/ATC/AIPlane.hxx
index 630767207..ed61205bc 100644
--- a/src/ATC/AIPlane.hxx
+++ b/src/ATC/AIPlane.hxx
@@ -83,7 +83,7 @@ public:
 	virtual LandingType GetLandingOption();
 	
 	// Return the callsign
-	inline string GetCallsign() {return plane.callsign;}
+	inline const string& GetCallsign() {return plane.callsign;}
 
 protected:
 	PlaneRec plane;
@@ -143,11 +143,11 @@ private:
 	// Outputs the transmission either on screen or as audio depending on user preference
 	// The refname is a string to identify this sample to the sound manager
 	// The repeating flag indicates whether the message should be repeated continuously or played once.
-	void Render(string refname, bool repeating);
+	void Render(const string& refname, bool repeating);
 
 	// Cease rendering a transmission.
 	// Requires the sound manager refname if audio, else "".
-	void NoRender(string refname);
+	void NoRender(const string& refname);
 	
 	// Rendering related stuff
 	bool voice;			// Flag - true if we are using voice
diff --git a/src/ATC/ATC.cxx b/src/ATC/ATC.cxx
index f6ee03ae4..55a9dc814 100644
--- a/src/ATC/ATC.cxx
+++ b/src/ATC/ATC.cxx
@@ -138,7 +138,7 @@ void FGATC::ReceiveUserCallback(int code) {
 	SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
 }
 
-void FGATC::SetResponseReqd(string rid) {
+void FGATC::SetResponseReqd(const string& rid) {
 	receiving = false;
 	responseReqd = true;
 	respond = false;	// TODO - this ignores the fact that more than one plane could call this before response
@@ -149,7 +149,7 @@ void FGATC::SetResponseReqd(string rid) {
 	responseTime = 1.8;		// TODO - randomize this slightly.
 }
 
-void FGATC::NotifyTransmissionFinished(string rid) {
+void FGATC::NotifyTransmissionFinished(const string& rid) {
 	//cout << "Transmission finished, callsign = " << rid << '\n';
 	receiving = false;
 	responseID = rid;
@@ -195,7 +195,7 @@ void FGATC::ImmediateTransmit(int callback_code) {
 void FGATC::ProcessCallback(int code) {
 }
 
-void FGATC::AddPlane(string pid) {
+void FGATC::AddPlane(const string& pid) {
 }
 
 int FGATC::RemovePlane() {
@@ -219,7 +219,7 @@ void FGATC::SetData(ATCData* d) {
 // Outputs the transmission either on screen or as audio depending on user preference
 // The refname is a string to identify this sample to the sound manager
 // The repeating flag indicates whether the message should be repeated continuously or played once.
-void FGATC::Render(string msg, string refname, bool repeating) {
+void FGATC::Render(string& msg, const string& refname, bool repeating) {
 	#ifdef ENABLE_AUDIO_SUPPORT
 	_voice = (_voiceOK && fgGetBool("/sim/sound/voice"));
 	if(_voice) {
@@ -259,7 +259,7 @@ void FGATC::Render(string msg, string refname, bool repeating) {
 
 
 // Cease rendering a transmission.
-void FGATC::NoRender(string refname) {
+void FGATC::NoRender(const string& refname) {
 	if(_playing) {
 		if(_voice) {
 			#ifdef ENABLE_AUDIO_SUPPORT		
diff --git a/src/ATC/ATC.hxx b/src/ATC/ATC.hxx
index cd4ab84db..2ad6185f6 100644
--- a/src/ATC/ATC.hxx
+++ b/src/ATC/ATC.hxx
@@ -117,7 +117,7 @@ public:
 	virtual void ReceiveUserCallback(int code);
 	
 	// Add plane to a stack
-	virtual void AddPlane(string pid);
+	virtual void AddPlane(const string& pid);
 	
 	// Remove plane from stack
 	virtual int RemovePlane();
@@ -136,9 +136,9 @@ public:
 	// Indicate that the frequency is in use
 	inline void SetFreqInUse() { freqClear = false; receiving = true; }
 	// Transmission to the ATC is finished and a response is required
-	void SetResponseReqd(string rid);
+	void SetResponseReqd(const string& rid);
 	// Transmission finished - let ATC decide if a response is reqd and clear freq if necessary
-	void NotifyTransmissionFinished(string rid);
+	void NotifyTransmissionFinished(const string& rid);
 	// Transmission finished and no response required
 	inline void ReleaseFreq() { freqClear = true; receiving = false; }	// TODO - check that the plane releasing the freq is the right one etc.
 	// The above 3 funcs under development!!
@@ -169,10 +169,10 @@ public:
 	inline void set_freq(const int fq) {freq = fq;}
 	inline int get_range() const { return range; }
 	inline void set_range(const int rg) {range = rg;}
-	inline string get_ident() { return ident; }
-	inline void set_ident(const string id) { ident = id; }
-	inline string get_name() { return name; }
-	inline void set_name(const string nm) { name = nm; }
+	inline const string& get_ident() { return ident; }
+	inline void set_ident(const string& id) { ident = id; }
+	inline const string& get_name() { return name; }
+	inline void set_name(const string& nm) { name = nm; }
 	
 protected:
 	
@@ -180,11 +180,11 @@ protected:
 	// Outputs the transmission either on screen or as audio depending on user preference
 	// The refname is a string to identify this sample to the sound manager
 	// The repeating flag indicates whether the message should be repeated continuously or played once.
-	void Render(string msg, string refname = "", bool repeating = false);
+	void Render(string& msg, const string& refname = "", bool repeating = false);
 	
 	// Cease rendering all transmission from this station.
 	// Requires the sound manager refname if audio, else "".
-	void NoRender(string refname);
+	void NoRender(const string& refname);
 	
 	// Transmit a message when channel becomes free of other dialog
     void Transmit(int callback_code = 0);
diff --git a/src/ATC/ATCDialog.cxx b/src/ATC/ATCDialog.cxx
index 42d8bf7be..031110e9e 100644
--- a/src/ATC/ATCDialog.cxx
+++ b/src/ATC/ATCDialog.cxx
@@ -245,7 +245,7 @@ void FGATCDialog::Update(double dt) {
 }
 
 // Add an entry
-void FGATCDialog::add_entry(string station, string transmission, string menutext, atc_type type, int code) {
+void FGATCDialog::add_entry(const string& station, const string& transmission, const string& menutext, atc_type type, int code) {
 
   ATCMenuEntry a;
 
@@ -446,7 +446,7 @@ void FGATCDialog::FreqDialog() {
 	FG_PUSH_PUI_DIALOG(atcFreqDialog);
 }
 
-void FGATCDialog::FreqDisplay(string ident) {
+void FGATCDialog::FreqDisplay(string& ident) {
 
 	atcUppercase(ident);
 	
diff --git a/src/ATC/ATCDialog.hxx b/src/ATC/ATCDialog.hxx
index 85a6721e6..2eddcbb61 100644
--- a/src/ATC/ATCDialog.hxx
+++ b/src/ATC/ATCDialog.hxx
@@ -66,10 +66,10 @@ public:
 	
 	void PopupCallback();
 	
-	void add_entry( string station, string transmission, string menutext, atc_type type, int code);
+	void add_entry( const string& station, const string& transmission, const string& menutext, atc_type type, int code);
 	
 	void remove_entry( const string &station, const string &trans, atc_type type );
-	
+
 	void remove_entry( const string &station, int code, atc_type type );
 	
 	// query the database whether the transmission is already registered; 
@@ -83,7 +83,7 @@ public:
 	
 	// Display the comm ATC frequencies for airport ident
 	// where ident is a valid ICAO code.
-	void FreqDisplay(string ident);
+	void FreqDisplay(string& ident);
 
 private:
 
diff --git a/src/ATC/ATCProjection.cxx b/src/ATC/ATCProjection.cxx
index 2db8598fe..5c7ed78c6 100644
--- a/src/ATC/ATCProjection.cxx
+++ b/src/ATC/ATCProjection.cxx
@@ -37,7 +37,7 @@ FGATCProjection::FGATCProjection() {
     correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
 }
 
-FGATCProjection::FGATCProjection(Point3D centre) {
+FGATCProjection::FGATCProjection(const Point3D& centre) {
     origin = centre;
     correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
 }
@@ -45,12 +45,12 @@ FGATCProjection::FGATCProjection(Point3D centre) {
 FGATCProjection::~FGATCProjection() {
 }
 
-void FGATCProjection::Init(Point3D centre) {
+void FGATCProjection::Init(const Point3D& centre) {
     origin = centre;
     correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
 }
 
-Point3D FGATCProjection::ConvertToLocal(Point3D pt) {
+Point3D FGATCProjection::ConvertToLocal(const Point3D& pt) {
     double delta_lat = pt.lat() - origin.lat();
     double delta_lon = pt.lon() - origin.lon();
 
@@ -60,7 +60,7 @@ Point3D FGATCProjection::ConvertToLocal(Point3D pt) {
     return(Point3D(x,y,0.0));
 }
 
-Point3D FGATCProjection::ConvertFromLocal(Point3D pt) {
+Point3D FGATCProjection::ConvertFromLocal(const Point3D& pt) {
 	double delta_lat = asin(pt.y() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
 	double delta_lon = (asin(pt.x() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
 	
@@ -79,13 +79,13 @@ FGATCAlignedProjection::FGATCAlignedProjection() {
 FGATCAlignedProjection::~FGATCAlignedProjection() {
 }
 
-void FGATCAlignedProjection::Init(Point3D centre, double heading) {
+void FGATCAlignedProjection::Init(const Point3D& centre, double heading) {
     origin = centre;
     theta = heading * DCL_DEGREES_TO_RADIANS;
     correction_factor = cos(origin.lat() * DCL_DEGREES_TO_RADIANS);
 }
 
-Point3D FGATCAlignedProjection::ConvertToLocal(Point3D pt) {
+Point3D FGATCAlignedProjection::ConvertToLocal(const Point3D& pt) {
     // convert from lat/lon to orthogonal
     double delta_lat = pt.lat() - origin.lat();
     double delta_lon = pt.lon() - origin.lon();
@@ -100,7 +100,7 @@ Point3D FGATCAlignedProjection::ConvertToLocal(Point3D pt) {
     return(Point3D(x,y,pt.elev()));
 }
 
-Point3D FGATCAlignedProjection::ConvertFromLocal(Point3D pt) {
+Point3D FGATCAlignedProjection::ConvertFromLocal(const Point3D& pt) {
 	//cout << "theta = " << theta << '\n';
 	//cout << "origin = " << origin << '\n';
     // de-align
diff --git a/src/ATC/ATCProjection.hxx b/src/ATC/ATCProjection.hxx
index 17db9f472..739c91a74 100644
--- a/src/ATC/ATCProjection.hxx
+++ b/src/ATC/ATCProjection.hxx
@@ -28,16 +28,16 @@ class FGATCProjection {
 
 public:
     FGATCProjection();
-    FGATCProjection(Point3D centre);
+    FGATCProjection(const Point3D& centre);
     ~FGATCProjection();
 
-    void Init(Point3D centre);
+    void Init(const Point3D& centre);
 
     // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
-    Point3D ConvertToLocal(Point3D pt);
+    Point3D ConvertToLocal(const Point3D& pt);
 
     // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
-    Point3D ConvertFromLocal(Point3D pt);
+    Point3D ConvertFromLocal(const Point3D& pt);
 
 private:
     Point3D origin;	// lat/lon of local area origin
@@ -54,13 +54,13 @@ public:
     FGATCAlignedProjection();
     ~FGATCAlignedProjection();
 
-    void Init(Point3D centre, double heading);
+    void Init(const Point3D& centre, double heading);
 
     // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
-    Point3D ConvertToLocal(Point3D pt);
+    Point3D ConvertToLocal(const Point3D& pt);
 
     // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
-    Point3D ConvertFromLocal(Point3D pt);
+    Point3D ConvertFromLocal(const Point3D& pt);
 
 private:
     Point3D origin;	// lat/lon of local area origin (the threshold)
diff --git a/src/ATC/ATCVoice.cxx b/src/ATC/ATCVoice.cxx
index 82721f420..02ef855a5 100644
--- a/src/ATC/ATCVoice.cxx
+++ b/src/ATC/ATCVoice.cxx
@@ -43,7 +43,7 @@ FGATCVoice::~FGATCVoice() {
 
 // Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
 // Return true if successful.
-bool FGATCVoice::LoadVoice(string voice) {
+bool FGATCVoice::LoadVoice(const string& voice) {
     // FIXME CLO: disabled to try to see if this is causign problemcs
     // return false;
 
diff --git a/src/ATC/ATCVoice.hxx b/src/ATC/ATCVoice.hxx
index 9d9fb7d92..965aeadcc 100644
--- a/src/ATC/ATCVoice.hxx
+++ b/src/ATC/ATCVoice.hxx
@@ -65,7 +65,7 @@ public:
 
 	// Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
 	// Return true if successful.	
-	bool LoadVoice(string voice);
+	bool LoadVoice(const string& voice);
 	
 	// Given a desired message, return a pointer to the data buffer and write the buffer length into len.
 	// Sets dataOK = true if the returned buffer is valid.
diff --git a/src/ATC/ATCdisplay.cxx b/src/ATC/ATCdisplay.cxx
index 0b3fa2a7f..cd05ca4d0 100644
--- a/src/ATC/ATCdisplay.cxx
+++ b/src/ATC/ATCdisplay.cxx
@@ -202,7 +202,7 @@ void FGATCDisplay::update(double dt) {
 	}
 }
 
-void FGATCDisplay::RegisterSingleMessage(string msg, double delay) {
+void FGATCDisplay::RegisterSingleMessage(const string& msg, double delay) {
 	//cout << msg << '\n';
 	atcMessage m;
 	m.msg = msg;
@@ -218,13 +218,13 @@ void FGATCDisplay::RegisterSingleMessage(string msg, double delay) {
 	//cout << "Single message registered\n";
 }
 
-void FGATCDisplay::RegisterRepeatingMessage(string msg) {
+void FGATCDisplay::RegisterRepeatingMessage(const string& msg) {
 	rep_msg = true;
 	rep_msg_str = msg;
 	return;
 }
 
-void FGATCDisplay::ChangeRepeatingMessage(string newmsg) {
+void FGATCDisplay::ChangeRepeatingMessage(const string& newmsg) {
 	rep_msg_str = newmsg;
 	change_msg_flag = true;
 	return;
diff --git a/src/ATC/ATCdisplay.hxx b/src/ATC/ATCdisplay.hxx
index 7b3ade925..66ec2146b 100644
--- a/src/ATC/ATCdisplay.hxx
+++ b/src/ATC/ATCdisplay.hxx
@@ -76,16 +76,16 @@ public:
 
     // Register a single message for display after a delay of delay seconds
     // Will automatically stop displaying after a suitable interval.
-    void RegisterSingleMessage(string msg, double delay = 0.0);	// OK - I know passing a string in and out is probably not good but it will have to do for now.
+    void RegisterSingleMessage(const string& msg, double delay = 0.0);
 
     // For now we will assume only one repeating message at once
     // This is not really robust
 
     // Register a continuously repeating message
-    void RegisterRepeatingMessage(string msg);
+    void RegisterRepeatingMessage(const string& msg);
 
     // Change a repeating message - assume that the message changes after the string has finished for now
-    void ChangeRepeatingMessage(string newmsg); 
+    void ChangeRepeatingMessage(const string& newmsg); 
 
     // Cancel the current repeating message
     void CancelRepeatingMessage();
diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx
index 8084b0822..6aa95a547 100644
--- a/src/ATC/ATCmgr.cxx
+++ b/src/ATC/ATCmgr.cxx
@@ -199,7 +199,7 @@ void FGATCMgr::update(double dt) {
 
 
 // Returns frequency in KHz - should I alter this to return in MHz?
-unsigned short int FGATCMgr::GetFrequency(string ident, atc_type tp) {
+unsigned short int FGATCMgr::GetFrequency(const string& ident, const atc_type& tp) {
 	ATCData test;
 	bool ok = current_commlist->FindByCode(ident, test, tp);
 	return(ok ? test.freq : 0);
@@ -208,7 +208,7 @@ unsigned short int FGATCMgr::GetFrequency(string ident, atc_type tp) {
 
 // Register the fact that the AI system wants to activate an airport
 // Might need more sophistication in this in the future - eg registration by aircraft call-sign.
-bool FGATCMgr::AIRegisterAirport(string ident) {
+bool FGATCMgr::AIRegisterAirport(const string& ident) {
 	SG_LOG(SG_ATC, SG_BULK, "AI registered airport " << ident << " with the ATC system");
 	//cout << "AI registered airport " << ident << " with the ATC system" << '\n';
 	if(airport_atc_map.find(ident) != airport_atc_map.end()) {
@@ -248,7 +248,7 @@ bool FGATCMgr::AIRegisterAirport(string ident) {
 
 // Register the fact that the comm radio is tuned to an airport
 // Channel is zero based
-bool FGATCMgr::CommRegisterAirport(string ident, int chan, atc_type tp) {
+bool FGATCMgr::CommRegisterAirport(const string& ident, int chan, const atc_type& tp) {
 	SG_LOG(SG_ATC, SG_BULK, "Comm channel " << chan << " registered airport " << ident);
 	//cout << "Comm channel " << chan << " registered airport " << ident << ' ' << tp << '\n';
 	if(airport_atc_map.find(ident) != airport_atc_map.end()) {
@@ -302,7 +302,7 @@ bool FGATCMgr::CommRegisterAirport(string ident, int chan, atc_type tp) {
 
 // Remove from list only if not needed by the AI system or the other comm channel
 // Note that chan is zero based.
-void FGATCMgr::CommRemoveFromList(string id, atc_type tp, int chan) {
+void FGATCMgr::CommRemoveFromList(const string& id, const atc_type& tp, int chan) {
 	SG_LOG(SG_ATC, SG_BULK, "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan);
 	//cout << "CommRemoveFromList called for airport " << id << " " << tp << " by channel " << chan << '\n';
 	if(airport_atc_map.find(id) != airport_atc_map.end()) {
@@ -366,7 +366,7 @@ void FGATCMgr::CommRemoveFromList(string id, atc_type tp, int chan) {
 
 // Remove from list - should only be called from above or similar
 // This function *will* remove it from the list regardless of who else might want it.
-void FGATCMgr::RemoveFromList(string id, atc_type tp) {
+void FGATCMgr::RemoveFromList(const string& id, const atc_type& tp) {
 	//cout << "FGATCMgr::RemoveFromList called..." << endl;
 	//cout << "Requested type = " << tp << endl;
 	//cout << "id = " << id << endl;
@@ -393,7 +393,7 @@ void FGATCMgr::RemoveFromList(string id, atc_type tp) {
 // Find in list - return a currently active ATC pointer given ICAO code and type
 // Return NULL if the given service is not in the list
 // - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
-FGATC* FGATCMgr::FindInList(string id, atc_type tp) {
+FGATC* FGATCMgr::FindInList(const string& id, const atc_type& tp) {
 	//cout << "Entering FindInList for " << id << ' ' << tp << endl;
 	atc_list_iterator it = atc_list.begin();
 	while(it != atc_list.end()) {
@@ -409,7 +409,7 @@ FGATC* FGATCMgr::FindInList(string id, atc_type tp) {
 }
 
 // Returns true if the airport is found in the map
-bool FGATCMgr::GetAirportATCDetails(string icao, AirportATC* a) {
+bool FGATCMgr::GetAirportATCDetails(const string& icao, AirportATC* a) {
 	if(airport_atc_map.find(icao) != airport_atc_map.end()) {
 		*a = *airport_atc_map[icao];
 		return(true);
@@ -423,7 +423,7 @@ bool FGATCMgr::GetAirportATCDetails(string icao, AirportATC* a) {
 // Returns NULL if service doesn't exist - calling function should check for this.
 // We really ought to make this private and call it from the CommRegisterAirport / AIRegisterAirport functions
 // - at the moment all these GetATC... functions exposed are just too complicated.
-FGATC* FGATCMgr::GetATCPointer(string icao, atc_type type) {
+FGATC* FGATCMgr::GetATCPointer(const string& icao, const atc_type& type) {
 	if(airport_atc_map.find(icao) == airport_atc_map.end()) {
 		//cout << "Unable to find " << icao << ' ' << type << " in the airport_atc_map" << endl;
 		return NULL;
@@ -500,7 +500,7 @@ FGATC* FGATCMgr::GetATCPointer(string icao, atc_type type) {
 // TODO - in the future this will get more complex and dole out country/airport
 // specific voices, and possible make sure that the same voice doesn't get used
 // at different airports in quick succession if a large enough selection are available.
-FGATCVoice* FGATCMgr::GetVoicePointer(atc_type type) {
+FGATCVoice* FGATCMgr::GetVoicePointer(const atc_type& type) {
 	// TODO - implement me better - maintain a list of loaded voices and other voices!!
 	if(voice) {
 		switch(type) {
diff --git a/src/ATC/ATCmgr.hxx b/src/ATC/ATCmgr.hxx
index 075138749..4ab2513d6 100644
--- a/src/ATC/ATCmgr.hxx
+++ b/src/ATC/ATCmgr.hxx
@@ -160,11 +160,11 @@ public:
     void update(double dt);
 
     // Returns true if the airport is found in the map
-    bool GetAirportATCDetails(string icao, AirportATC* a);
+    bool GetAirportATCDetails(const string& icao, AirportATC* a);
 
     // Return a pointer to a given sort of ATC at a given airport and activate if necessary
 	// Returns NULL if service doesn't exist - calling function should check for this.
-    FGATC* GetATCPointer(string icao, atc_type type);
+    FGATC* GetATCPointer(const string& icao, const atc_type& type);
 	
 	// Return a pointer to an appropriate voice for a given type of ATC
 	// creating the voice if necessary - ie. make sure exactly one copy
@@ -173,7 +173,7 @@ public:
 	// TODO - in the future this will get more complex and dole out country/airport
 	// specific voices, and possible make sure that the same voice doesn't get used
 	// at different airports in quick succession if a large enough selection are available.
-	FGATCVoice* GetVoicePointer(atc_type type);
+	FGATCVoice* GetVoicePointer(const atc_type& type);
 	
 	atc_type GetComm1ATCType() { return(comm_type[0]); }
 	FGATC* GetComm1ATCPointer() { return(comm_atc_ptr[0]); }
@@ -182,29 +182,29 @@ public:
 	
 	// Get the frequency of a given service at a given airport
 	// Returns zero if not found
-	unsigned short int GetFrequency(string ident, atc_type tp);
+	unsigned short int GetFrequency(const string& ident, const atc_type& tp);
 	
 	// Register the fact that the AI system wants to activate an airport
-	bool AIRegisterAirport(string ident);
+	bool AIRegisterAirport(const string& ident);
 	
 	// Register the fact that the comm radio is tuned to an airport
-	bool CommRegisterAirport(string ident, int chan, atc_type tp);
+	bool CommRegisterAirport(const string& ident, int chan, const atc_type& tp);
 	
 private:
 
     // Remove a class from the atc_list and delete it from memory
 	// *if* no other comm channel or AI plane is using it.
-    void CommRemoveFromList(string id, atc_type tp, int chan);
+    void CommRemoveFromList(const string& id, const atc_type& tp, int chan);
 
     // Remove a class from the atc_list and delete it from memory
 	// Should be called from the above - not directly!!
-    void RemoveFromList(string id, atc_type tp);
+    void RemoveFromList(const string& id, const atc_type& tp);
 
     // Return a pointer to a class in the list given ICAO code and type
 	// (external interface to this is through GetATCPointer) 
 	// Return NULL if the given service is not in the list
 	// - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
-    FGATC* FindInList(string id, atc_type tp);
+    FGATC* FindInList(const string& id, const atc_type& tp);
 
     // Search the specified channel for stations on the same frequency and in range.
     void FreqSearch(int channel);
diff --git a/src/ATC/ATCutils.cxx b/src/ATC/ATCutils.cxx
index 0b51b550f..5387880c7 100644
--- a/src/ATC/ATCutils.cxx
+++ b/src/ATC/ATCutils.cxx
@@ -187,7 +187,7 @@ string GetCompassDirection(double h) {
 //================================================================================================================
 
 // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2) {
+double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2) {
 	double x;	//East-West separation
 	double y;	//North-South separation
 	double z;	//Horizontal separation - z = sqrt(x^2 + y^2)
@@ -226,7 +226,7 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou
 // Given a position (lat/lon/elev), heading and vertical angle (degrees), and distance (meters), calculate the new position.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Assumes that the ground is not hit!!!  Expects heading and angle in degrees, distance in meters. 
-Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance) {
+Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance) {
 	//cout << setprecision(10) << pos.lon() << ' ' << pos.lat() << '\n';
 	heading *= DCL_DEGREES_TO_RADIANS;
 	angle *= DCL_DEGREES_TO_RADIANS;
@@ -259,7 +259,7 @@ Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, doubl
 // Get a heading in degrees from one lat/lon to another.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Warning - at the moment we are not checking for identical points - currently it returns 0 in this instance.
-double GetHeadingFromTo(const Point3D A, const Point3D B) {
+double GetHeadingFromTo(const Point3D& A, const Point3D& B) {
 	double latA = A.lat() * DCL_DEGREES_TO_RADIANS;
 	double lonA = A.lon() * DCL_DEGREES_TO_RADIANS;
 	double latB = B.lat() * DCL_DEGREES_TO_RADIANS;
@@ -354,7 +354,7 @@ Point3D dclGetAirportPos( const string& id ) {
 
 // Runway stuff
 // Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D pt, const FGRunway& rwy) {
+bool OnRunway(const Point3D& pt, const FGRunway& rwy) {
 	FGATCAlignedProjection ortho;
 	Point3D centre(rwy._lon, rwy._lat, 0.0);	// We don't need the elev
 	ortho.Init(centre, rwy._heading);
diff --git a/src/ATC/ATCutils.hxx b/src/ATC/ATCutils.hxx
index 204765086..2acfc9d18 100644
--- a/src/ATC/ATCutils.hxx
+++ b/src/ATC/ATCutils.hxx
@@ -72,7 +72,7 @@ string GetCompassDirection(double h);
 ********************************/
 
 // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2);
+double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2);
 
 // Given a point and a line, get the HORIZONTAL shortest distance from the point to a point on the line.
 // Expects to be fed orthogonal co-ordinates, NOT lat & lon !
@@ -80,10 +80,10 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou
 
 // Given a position (lat/lon/elev), heading, vertical angle, and distance, calculate the new position.
 // Assumes that the ground is not hit!!!  Expects heading and angle in degrees, distance in meters.
-Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance);
+Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance);
 
 // Get a heading from one lat/lon to another (in degrees)
-double GetHeadingFromTo(const Point3D A, const Point3D B);
+double GetHeadingFromTo(const Point3D& A, const Point3D& B);
 
 // Given a heading (in degrees), bound it from 0 -> 360
 void dclBoundHeading(double &hdg);
@@ -118,5 +118,5 @@ Point3D dclGetAirportPos( const string& id );
 ****************/
 
 // Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D pt, const FGRunway& rwy);
+bool OnRunway(const Point3D& pt, const FGRunway& rwy);
 
diff --git a/src/ATC/approach.cxx b/src/ATC/approach.cxx
index c2944ac0c..0d46355a3 100644
--- a/src/ATC/approach.cxx
+++ b/src/ATC/approach.cxx
@@ -29,6 +29,7 @@
 #include "ATCDialog.hxx"
 
 #include <Airports/runways.hxx>
+#include <simgear/constants.h>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/misc/sg_path.hxx>
 
@@ -611,7 +612,7 @@ void FGApproach::update_plane_dat() {
 // =======================================================================
 // Add plane to Approach list
 // =======================================================================
-void FGApproach::AddPlane(string pid) {
+void FGApproach::AddPlane(const string& pid) {
 
   int i;
   for ( i=0; i<num_planes; i++) {
@@ -654,8 +655,8 @@ double FGApproach::calc_psl_dist(const double &h1, const double &d1,
   x3 *= sqrt(val2);
   y3 *= sqrt(val2);
   double da = fabs(atan2(y3,x3) - atan2(y1-y2,x1-x2));
-  if ( da > SGD_PI ) da -= 2*SGD_PI;
-  if ( fabs(da) > SGD_PI/2.) {
+  if ( da > SGD_PI ) da -= SGD_2PI;
+  if ( fabs(da) > SGD_PI_2) {
     //if ( x3*(x1-x2) < 0.0 && y3*(y1-y2) < 0.0) {
     x3 *= -1.0;
     y3 *= -1.0;
@@ -665,7 +666,7 @@ double FGApproach::calc_psl_dist(const double &h1, const double &d1,
   double dis2   = y1-y2-y3;
   dis = sqrt(dis);
   da = atan2(dis2,dis1);
-  if ( da < 0.0 ) da  += 2*SGD_PI;
+  if ( da < 0.0 ) da  += SGD_2PI;
   if ( da < a3 )  dis *= -1.0;
   //cout << dis1 << " " << dis2 << " " << da*SGD_RADIANS_TO_DEGREES << " " << h3
   //     << " " << sqrt(dis1*dis1 + dis2*dis2) << " " << dis << endl;
diff --git a/src/ATC/approach.hxx b/src/ATC/approach.hxx
index 41e32f22a..282f0c4bd 100644
--- a/src/ATC/approach.hxx
+++ b/src/ATC/approach.hxx
@@ -153,14 +153,14 @@ public:
   // Add new plane to stack if not already registered 
   // Input:  pid - id of plane (name) 
   // Output: "true" if added; "false" if already existend
-  void AddPlane(string pid);
+  void AddPlane(const string& pid);
 
   // Remove plane from stack if out of range
   int RemovePlane();
   
   inline double get_bucket() const { return bucket; }
   inline int get_pnum() const { return num_planes; }
-  inline string get_trans_ident() { return trans_ident; }
+  inline const string& get_trans_ident() { return trans_ident; }
   
 private:
 
diff --git a/src/ATC/atis.hxx b/src/ATC/atis.hxx
index 741e9943d..4cd303ada 100644
--- a/src/ATC/atis.hxx
+++ b/src/ATC/atis.hxx
@@ -79,8 +79,8 @@ class FGATIS : public FGATC {
 	void Update(double dt);
 	
 	//inline void set_type(const atc_type tp) {type = tp;}
-	inline string get_trans_ident() { return trans_ident; }
-	inline void set_refname(string r) { refname = r; } 
+	inline const string& get_trans_ident() { return trans_ident; }
+	inline void set_refname(const string& r) { refname = r; } 
 	
 	private:
 	
diff --git a/src/ATC/commlist.cxx b/src/ATC/commlist.cxx
index 18e171730..af2da4117 100644
--- a/src/ATC/commlist.cxx
+++ b/src/ATC/commlist.cxx
@@ -50,7 +50,7 @@ FGCommList::~FGCommList( void ) {
 
 
 // load the navaids and build the map
-bool FGCommList::init( SGPath path ) {
+bool FGCommList::init( const SGPath& path ) {
 
 	SGPath temp = path;
     commlist_freq.erase(commlist_freq.begin(), commlist_freq.end());
@@ -70,7 +70,7 @@ bool FGCommList::init( SGPath path ) {
 }
 	
 
-bool FGCommList::LoadComms(SGPath path) {
+bool FGCommList::LoadComms(const SGPath& path) {
 
     sg_gzifstream fin( path.str() );
     if ( !fin.is_open() ) {
@@ -272,7 +272,7 @@ double FGCommList::FindClosest( double lon, double lat, double elev, ATCData& ad
 // Find by Airport code.
 // This is basically a wrapper for a call to the airport database to get the airport
 // position followed by a call to FindByPos(...)
-bool FGCommList::FindByCode( string ICAO, ATCData& ad, atc_type tp ) {
+bool FGCommList::FindByCode( const string& ICAO, ATCData& ad, atc_type tp ) {
     FGAirport a;
     if ( dclFindAirportID( ICAO, &a ) ) {
 		comm_list_type stations;
@@ -296,7 +296,7 @@ bool FGCommList::FindByCode( string ICAO, ATCData& ad, atc_type tp ) {
 
 // TODO - this function should move somewhere else eventually!
 // Return an appropriate call-sign for an ATIS transmission.
-int FGCommList::GetCallSign( string apt_id, int hours, int mins )
+int FGCommList::GetCallSign( const string& apt_id, int hours, int mins )
 {
 	atis_transmission_type tran;
 	
diff --git a/src/ATC/commlist.hxx b/src/ATC/commlist.hxx
index 8520b4b2b..73c17e72d 100644
--- a/src/ATC/commlist.hxx
+++ b/src/ATC/commlist.hxx
@@ -68,7 +68,7 @@ public:
     ~FGCommList();
 
     // load all comm frequencies and build the map
-    bool init( SGPath path );
+    bool init( const SGPath& path );
 
     // query the database for the specified frequency, lon and lat are
     // in degrees, elev is in meters.
@@ -97,11 +97,11 @@ public:
 	double FindClosest( double lon, double lat, double elev, ATCData& ad, atc_type tp = INVALID, double max_range = 100.0 );
 	
 	// Find by Airport code.
-	bool FindByCode( string ICAO, ATCData& ad, atc_type tp = INVALID );
+	bool FindByCode( const string& ICAO, ATCData& ad, atc_type tp = INVALID );
 
     // Return the callsign for an ATIS transmission given transmission time and airport id
 	// This maybe should get moved somewhere else!!
-    int GetCallSign( string apt_id, int hours, int mins );
+    int GetCallSign( const string& apt_id, int hours, int mins );
 	
 private:
 	
@@ -112,7 +112,7 @@ private:
 	comm_map_type commlist_bck;
 
 	// Load comms from a specified path (which must include the filename)	
-	bool LoadComms(SGPath path);
+	bool LoadComms(const SGPath& path);
 
 //----------- This stuff is left over from atislist.[ch]xx and maybe should move somewhere else
 	// Add structure and map for storing a log of atis transmissions
diff --git a/src/ATC/ground.cxx b/src/ATC/ground.cxx
index ab959cd4d..de018cae6 100644
--- a/src/ATC/ground.cxx
+++ b/src/ATC/ground.cxx
@@ -70,7 +70,7 @@ FGGround::FGGround() {
 	aptElev = 0.0;
 }
 
-FGGround::FGGround(string id) {
+FGGround::FGGround(const string& id) {
 	ATCmgr = globals->get_ATC_mgr();
 	networkLoadOK = false;
 	ground_traffic.erase(ground_traffic.begin(), ground_traffic.end());
@@ -456,7 +456,7 @@ Gate* FGGround::GetGateNode() {
 }
 
 
-node* FGGround::GetHoldShortNode(string rwyID) {
+node* FGGround::GetHoldShortNode(const string& rwyID) {
 	return(NULL);	// TODO - either implement me or remove me!!!
 }
 
@@ -464,7 +464,7 @@ node* FGGround::GetHoldShortNode(string rwyID) {
 // WARNING - This is hardwired to my prototype logical network format
 // and will almost certainly change when Bernie's stuff comes on-line.
 // Returns NULL if it can't find a valid node.
-node* FGGround::GetThresholdNode(string rwyID) {
+node* FGGround::GetThresholdNode(const string& rwyID) {
 	// For now go through all the nodes and parse their names
 	// Maybe in the future we'll map threshold nodes by ID
 	//cout << "Size of network is " << network.size() << '\n';
@@ -499,7 +499,7 @@ ground_network_path_type FGGround::GetPath(node* A, node* B) {
 };
 
 // Get a path from a node to a runway threshold
-ground_network_path_type FGGround::GetPath(node* A, string rwyID) {
+ground_network_path_type FGGround::GetPath(node* A, const string& rwyID) {
 	node* b = GetThresholdNode(rwyID);
 	if(b == NULL) {
 		SG_LOG(SG_ATC, SG_ALERT, "ERROR - unable to find path to runway theshold in ground.cxx for airport " << ident << '\n');
@@ -512,7 +512,7 @@ ground_network_path_type FGGround::GetPath(node* A, string rwyID) {
 
 // Get a path from a node to a runway hold short point
 // Bit of a hack this at the moment!
-ground_network_path_type FGGround::GetPathToHoldShort(node* A, string rwyID) {
+ground_network_path_type FGGround::GetPathToHoldShort(node* A, const string& rwyID) {
 	ground_network_path_type path = GetPath(A, rwyID);
 	path.pop_back();	// That should be the threshold stripped of 
 	path.pop_back();	// and that should be the arc from hold short to threshold
@@ -661,12 +661,12 @@ ground_network_path_type FGGround::GetShortestPath(node* A, node* B) {
 
 // Return a list of exits from a given runway
 // It is up to the calling function to check for non-zero size of returned array before use
-node_array_type FGGround::GetExits(string rwyID) {
+node_array_type FGGround::GetExits(const string& rwyID) {
 	// FIXME - get a 07L or similar in here and we're stuffed!!!
 	return(runways[atoi(rwyID.c_str())].exits);
 }
 
-void FGGround::RequestDeparture(PlaneRec plane, FGAIEntity* requestee) {
+void FGGround::RequestDeparture(const PlaneRec& plane, FGAIEntity* requestee) {
 	// For now we'll just automatically clear all planes to the runway hold.
 	// This communication needs to be delayed 20 sec or so from receiving the request.
 	// Even if display=false we still need to start the timer in case display=true when communication starts.
diff --git a/src/ATC/ground.hxx b/src/ATC/ground.hxx
index ffc668c4a..84a296442 100644
--- a/src/ATC/ground.hxx
+++ b/src/ATC/ground.hxx
@@ -225,19 +225,19 @@ class FGGround : public FGATC {
 
 public:
 	FGGround();
-	FGGround(string id);
+	FGGround(const string& id);
 	~FGGround();
     void Init();
 
     void Update(double dt);
 	
-	inline string get_trans_ident() { return trans_ident; }
+	inline const string& get_trans_ident() { return trans_ident; }
 
     // Contact ground control on arrival, assumed to request any gate
     //void NewArrival(plane_rec plane);
 
     // Contact ground control on departure, assumed to request currently active runway.
-    void RequestDeparture(PlaneRec plane, FGAIEntity* requestee);
+    void RequestDeparture(const PlaneRec& plane, FGAIEntity* requestee);
 
     // Contact ground control when the calling routine doesn't know if arrival
     // or departure is appropriate.
@@ -256,22 +256,22 @@ public:
 	Gate* GetGateNode();
 	
 	// Return a pointer to a hold short node
-	node* GetHoldShortNode(string rwyID);
+	node* GetHoldShortNode(const string& rwyID);
 	
 	// Runway stuff - this might change in the future.
 	// Get a list of exits from a given runway
 	// It is up to the calling function to check for non-zero size of returned array before use
-	node_array_type GetExits(string rwyID);
+	node_array_type GetExits(const string& rwyID);
 	
 	// Get a path from one node to another
 	ground_network_path_type GetPath(node* A, node* B);
 	
 	// Get a path from a node to a runway threshold
-	ground_network_path_type GetPath(node* A, string rwyID);
+	ground_network_path_type GetPath(node* A, const string& rwyID);
 	
 	// Get a path from a node to a runway hold short point
 	// Bit of a hack this at the moment!
-	ground_network_path_type GetPathToHoldShort(node* A, string rwyID);
+	ground_network_path_type GetPathToHoldShort(node* A, const string& rwyID);
 
 private:
 	FGATCMgr* ATCmgr;	
@@ -351,7 +351,7 @@ private:
 	
 	// Return a pointer to the node at a runway threshold
 	// Returns NULL if unsuccessful.
-	node* GetThresholdNode(string rwyID);
+	node* GetThresholdNode(const string& rwyID);
 	
 	// A shortest path algorithm from memory (I can't find the bl&*dy book again!)
 	ground_network_path_type GetShortestPath(node* A, node* B); 
diff --git a/src/ATC/tower.cxx b/src/ATC/tower.cxx
index 11d076ebc..cbd8ddc9f 100644
--- a/src/ATC/tower.cxx
+++ b/src/ATC/tower.cxx
@@ -72,7 +72,7 @@ TowerPlaneRec::TowerPlaneRec() :
 	plane.callsign = "UNKNOWN";
 }
 
-TowerPlaneRec::TowerPlaneRec(PlaneRec p) :
+TowerPlaneRec::TowerPlaneRec(const PlaneRec& p) :
 	planePtr(NULL),
 	clearedToLand(false),
 	clearedToLineUp(false),
@@ -99,7 +99,7 @@ TowerPlaneRec::TowerPlaneRec(PlaneRec p) :
 	plane = p;
 }
 
-TowerPlaneRec::TowerPlaneRec(Point3D pt) :
+TowerPlaneRec::TowerPlaneRec(const Point3D& pt) :
 	planePtr(NULL),
 	clearedToLand(false),
 	clearedToLineUp(false),
@@ -127,7 +127,7 @@ TowerPlaneRec::TowerPlaneRec(Point3D pt) :
 	pos = pt;
 }
 
-TowerPlaneRec::TowerPlaneRec(PlaneRec p, Point3D pt) :
+TowerPlaneRec::TowerPlaneRec(const PlaneRec& p, const Point3D& pt) :
 	planePtr(NULL),
 	clearedToLand(false),
 	clearedToLineUp(false),
@@ -1435,7 +1435,7 @@ void FGTower::DoRwyDetails() {
 
 // Figure out if a given position lies on the active runway
 // Might have to change when we consider more than one active rwy.
-bool FGTower::OnActiveRunway(Point3D pt) {
+bool FGTower::OnActiveRunway(const Point3D& pt) {
 	// TODO - check that the centre calculation below isn't confused by displaced thesholds etc.
 	Point3D xyc((rwy.end1ortho.x() + rwy.end2ortho.x())/2.0, (rwy.end1ortho.y() + rwy.end2ortho.y())/2.0, 0.0);
 	Point3D xyp = ortho.ConvertToLocal(pt);
@@ -1454,7 +1454,7 @@ bool FGTower::OnActiveRunway(Point3D pt) {
 
 // Figure out if a given position lies on any runway or not
 // Only call this at startup - reading the runways database is expensive and needs to be fixed!
-bool FGTower::OnAnyRunway(Point3D pt) {
+bool FGTower::OnAnyRunway(const Point3D& pt) {
 	ATCData ad;
 	double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 10.0);
 	if(dist < 0.0) {
@@ -1482,7 +1482,7 @@ bool FGTower::OnAnyRunway(Point3D pt) {
 
 
 // Returns true if successful
-bool FGTower::RemoveFromTrafficList(string id) {
+bool FGTower::RemoveFromTrafficList(const string& id) {
 	tower_plane_rec_list_iterator twrItr;
 	for(twrItr = trafficList.begin(); twrItr != trafficList.end(); twrItr++) {
 		TowerPlaneRec* tpr = *twrItr;
@@ -1498,7 +1498,7 @@ bool FGTower::RemoveFromTrafficList(string id) {
 
 
 // Returns true if successful
-bool FGTower::RemoveFromAppList(string id) {
+bool FGTower::RemoveFromAppList(const string& id) {
 	tower_plane_rec_list_iterator twrItr;
 	for(twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
 		TowerPlaneRec* tpr = *twrItr;
@@ -1513,7 +1513,7 @@ bool FGTower::RemoveFromAppList(string id) {
 }
 
 // Returns true if successful
-bool FGTower::RemoveFromRwyList(string id) {
+bool FGTower::RemoveFromRwyList(const string& id) {
 	tower_plane_rec_list_iterator twrItr;
 	for(twrItr = rwyList.begin(); twrItr != rwyList.end(); twrItr++) {
 		TowerPlaneRec* tpr = *twrItr;
@@ -1900,7 +1900,7 @@ double FGTower::GetTrafficETA(unsigned int list_pos, bool printout) {
 }
 	
 
-void FGTower::ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation) {
+void FGTower::ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, tower_traffic_type operation) {
 	// HACK - assume that anything contacting at hold short is new for now - FIXME LATER
 	TowerPlaneRec* t = new TowerPlaneRec;
 	t->plane = plane;
@@ -1934,7 +1934,7 @@ void FGTower::ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_tra
 
 // Register the presence of an AI plane at a point where contact would already have been made in real life
 // CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
-void FGTower::RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg) {
+void FGTower::RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_traffic_type& op, const PatternLeg& lg) {
 	// At the moment this is only going to be tested with inserting an AI plane on downwind
 	TowerPlaneRec* t = new TowerPlaneRec;
 	t->plane = plane;
@@ -1954,7 +1954,7 @@ void FGTower::RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type
 	doThresholdUseOrder();
 }
 
-void FGTower::DeregisterAIPlane(string id) {
+void FGTower::DeregisterAIPlane(const string& id) {
 	RemovePlane(id);
 }
 
@@ -1962,7 +1962,7 @@ void FGTower::DeregisterAIPlane(string id) {
 // eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
 // This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
 // opt defaults to AIP_LT_UNKNOWN
-void FGTower::VFRArrivalContact(string ID, LandingType opt) {
+void FGTower::VFRArrivalContact(const string& ID, const LandingType& opt) {
 	//cout << "USER Request Landing Clearance called for ID " << ID << '\n';
 	
 	// For now we'll assume that the user is a light plane and can get him/her to join the circuit if necessary.
@@ -2013,7 +2013,7 @@ void FGTower::VFRArrivalContact(string ID, LandingType opt) {
 }
 
 // landingType defaults to AIP_LT_UNKNOWN
-void FGTower::VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingType lt) {
+void FGTower::VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, const LandingType& lt) {
 	//cout << "VFRArrivalContact called for plane " << plane.callsign << " at " << ident << '\n';
 	// Possible hack - assume this plane is new for now - TODO - should check really
 	TowerPlaneRec* t = new TowerPlaneRec;
@@ -2038,17 +2038,18 @@ void FGTower::VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingTyp
 	AddToTrafficList(t);
 }
 
-void FGTower::RequestDepartureClearance(string ID) {
+void FGTower::RequestDepartureClearance(const string& ID) {
 	//cout << "Request Departure Clearance called...\n";
 }
 	
-void FGTower::ReportFinal(string ID) {
+void FGTower::ReportFinal(const string& ID) {
 	//cout << "Report Final Called at tower " << ident << " by plane " << ID << '\n';
+	string uid=ID;
 	if(ID == "USER") {
-		ID = fgGetString("/sim/user/callsign");
+		uid = fgGetString("/sim/user/callsign");
 		current_atcdialog->remove_entry(ident, USER_REPORT_3_MILE_FINAL, TOWER);
 	}
-	TowerPlaneRec* t = FindPlane(ID);
+	TowerPlaneRec* t = FindPlane(uid);
 	if(t) {
 		t->finalReported = true;
 		t->finalAcknowledged = false;
@@ -2065,12 +2066,13 @@ void FGTower::ReportFinal(string ID) {
 	}
 }
 
-void FGTower::ReportLongFinal(string ID) {
+void FGTower::ReportLongFinal(const string& ID) {
+	string uid=ID;
 	if(ID == "USER") {
-		ID = fgGetString("/sim/user/callsign");
+		uid = fgGetString("/sim/user/callsign");
 		current_atcdialog->remove_entry(ident, USER_REPORT_3_MILE_FINAL, TOWER);
 	}
-	TowerPlaneRec* t = FindPlane(ID);
+	TowerPlaneRec* t = FindPlane(uid);
 	if(t) {
 		t->longFinalReported = true;
 		t->longFinalAcknowledged = false;
@@ -2086,13 +2088,14 @@ void FGTower::ReportLongFinal(string ID) {
 //void FGTower::ReportMiddleMarker(string ID);
 //void FGTower::ReportInnerMarker(string ID);
 
-void FGTower::ReportRunwayVacated(string ID) {
+void FGTower::ReportRunwayVacated(const string& ID) {
 	//cout << "Report Runway Vacated Called at tower " << ident << " by plane " << ID << '\n';
+	string uid=ID;
 	if(ID == "USER") {
-		ID = fgGetString("/sim/user/callsign");
+		uid = fgGetString("/sim/user/callsign");
 		current_atcdialog->remove_entry(ident, USER_REPORT_RWY_VACATED, TOWER);
 	}
-	TowerPlaneRec* t = FindPlane(ID);
+	TowerPlaneRec* t = FindPlane(uid);
 	if(t) {
 		//cout << "Found it...\n";
 		t->rwyVacatedReported = true;
@@ -2104,7 +2107,7 @@ void FGTower::ReportRunwayVacated(string ID) {
 	}
 }
 
-TowerPlaneRec* FGTower::FindPlane(string ID) {
+TowerPlaneRec* FGTower::FindPlane(const string& ID) {
 	//cout << "FindPlane called for " << ID << "...\n";
 	tower_plane_rec_list_iterator twrItr;
 	// Do the approach list first
@@ -2137,7 +2140,7 @@ TowerPlaneRec* FGTower::FindPlane(string ID) {
 	return(NULL);
 }
 
-void FGTower::RemovePlane(string ID) {
+void FGTower::RemovePlane(const string& ID) {
 	//cout << ident << " RemovePlane called for " << ID << '\n';
 	// We have to be careful here - we want to erase the plane from all lists it is in,
 	// but we can only delete it once, AT THE END.
@@ -2197,13 +2200,14 @@ void FGTower::RemovePlane(string ID) {
 	if(t) delete t;
 }
 
-void FGTower::ReportDownwind(string ID) {
+void FGTower::ReportDownwind(const string& ID) {
 	//cout << "ReportDownwind(...) called\n";
+	string uid=ID;
 	if(ID == "USER") {
-		ID = fgGetString("/sim/user/callsign");
+		uid = fgGetString("/sim/user/callsign");
 		current_atcdialog->remove_entry(ident, USER_REPORT_DOWNWIND, TOWER);
 	}
-	TowerPlaneRec* t = FindPlane(ID);
+	TowerPlaneRec* t = FindPlane(uid);
 	if(t) {
 		t->downwindReported = true;
 		responseReqd = true;
@@ -2227,13 +2231,14 @@ void FGTower::ReportDownwind(string ID) {
 	}
 }
 
-void FGTower::ReportGoingAround(string ID) {
+void FGTower::ReportGoingAround(const string& ID) {
+	string uid=ID;
 	if(ID == "USER") {
-		ID = fgGetString("/sim/user/callsign");
+		uid = fgGetString("/sim/user/callsign");
 		RemoveAllUserDialogOptions();	// TODO - it would be much more efficient if ATCDialog simply had a clear() function!!!
 		current_atcdialog->add_entry(ident, "@AP Tower @CS Downwind @RW", "Report Downwind", TOWER, (int)USER_REPORT_DOWNWIND);
 	}
-	TowerPlaneRec* t = FindPlane(ID);
+	TowerPlaneRec* t = FindPlane(uid);
 	if(t) {
 		//t->goAroundReported = true;  // No need to set this until we start responding to it.
 		responseReqd = false;	// might change in the future but for now we'll not distract them during the go-around.
diff --git a/src/ATC/tower.hxx b/src/ATC/tower.hxx
index aaaf5387b..de0bf632f 100644
--- a/src/ATC/tower.hxx
+++ b/src/ATC/tower.hxx
@@ -73,9 +73,9 @@ class TowerPlaneRec {
 public:
 	
 	TowerPlaneRec();
-	TowerPlaneRec(PlaneRec p);
-	TowerPlaneRec(Point3D pt);
-	TowerPlaneRec(PlaneRec p, Point3D pt);
+	TowerPlaneRec(const PlaneRec& p);
+	TowerPlaneRec(const Point3D& pt);
+	TowerPlaneRec(const PlaneRec& p, const Point3D& pt);
 	
 	FGAIPlane* planePtr;	// This might move to the planeRec eventually
 	PlaneRec plane;
@@ -110,7 +110,6 @@ public:
 	PatternLeg leg;
 	
 	LandingType landingType;
-	
 	bool isUser;	// true if this plane is the user
 };
 
@@ -136,39 +135,39 @@ public:
 	// Contact tower for VFR approach
 	// eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
 	// This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
-	void VFRArrivalContact(string ID, LandingType opt = AIP_LT_UNKNOWN);
+	void VFRArrivalContact(const string& ID, const LandingType& opt = AIP_LT_UNKNOWN);
 	// For the AI planes...
-	void VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingType lt = AIP_LT_UNKNOWN);
+	void VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, const LandingType& lt = AIP_LT_UNKNOWN);
 	
-	void RequestDepartureClearance(string ID);	
-	void ReportFinal(string ID);
-	void ReportLongFinal(string ID);
-	void ReportOuterMarker(string ID);
-	void ReportMiddleMarker(string ID);
-	void ReportInnerMarker(string ID);
-	void ReportRunwayVacated(string ID);
-	void ReportReadyForDeparture(string ID);
-	void ReportDownwind(string ID);
-	void ReportGoingAround(string ID);
+	void RequestDepartureClearance(const string& ID);
+	void ReportFinal(const string& ID);
+	void ReportLongFinal(const string& ID);
+	void ReportOuterMarker(const string& ID);
+	void ReportMiddleMarker(const string& ID);
+	void ReportInnerMarker(const string& ID);
+	void ReportRunwayVacated(const string& ID);
+	void ReportReadyForDeparture(const string& ID);
+	void ReportDownwind(const string& ID);
+	void ReportGoingAround(const string& ID);
 	
 	// Contact tower when at a hold short for departure - for now we'll assume plane - maybe vehicles might want to cross runway eventually?
-	void ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation);
+	void ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, tower_traffic_type operation);
 	
 	// Register the presence of an AI plane at a point where contact would already have been made in real life
 	// CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
-	void RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg = LEG_UNKNOWN);
+	void RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_traffic_type& op, const PatternLeg& lg = LEG_UNKNOWN);
 	
 	// Deregister and remove an AI plane.
-	void DeregisterAIPlane(string id);
+	void DeregisterAIPlane(const string& id);
 	
 	// Public interface to the active runway - this will get more complex 
 	// in the future and consider multi-runway use, airplane weight etc.
-	inline string GetActiveRunway() { return activeRwy; }
-	inline RunwayDetails GetActiveRunwayDetails() { return rwy; }
+	inline const string& GetActiveRunway() { return activeRwy; }
+	inline const RunwayDetails& GetActiveRunwayDetails() { return rwy; }
 	// Get the pattern direction of the active rwy.
 	inline int GetPatternDirection() { return rwy.patternDirection; }
 	
-	inline string get_trans_ident() { return trans_ident; }
+	inline const string& get_trans_ident() { return trans_ident; }
 	
 	inline FGGround* GetGroundPtr() { return ground; }
 	
@@ -205,17 +204,17 @@ private:
 	void ClearHoldingPlane(TowerPlaneRec* t);
 	
 	// Find a pointer to plane of callsign ID within the internal data structures
-	TowerPlaneRec* FindPlane(string ID);
+	TowerPlaneRec* FindPlane(const string& ID);
 	
 	// Remove and delete all instances of a plane with a given ID
-	void RemovePlane(string ID);
+	void RemovePlane(const string& ID);
 	
 	// Figure out if a given position lies on the active runway
 	// Might have to change when we consider more than one active rwy.
-	bool OnActiveRunway(Point3D pt);
+	bool OnActiveRunway(const Point3D& pt);
 	
 	// Figure out if a given position lies on a runway or not
-	bool OnAnyRunway(Point3D pt);
+	bool OnAnyRunway(const Point3D& pt);
 	
 	// Calculate the eta of a plane to the threshold.
 	// For ground traffic this is the fastest they can get there.
@@ -305,9 +304,9 @@ private:
 	tower_plane_rec_list_iterator vacatedListItr;
 	
 	// Returns true if successful
-	bool RemoveFromTrafficList(string id);
-	bool RemoveFromAppList(string id);
-	bool RemoveFromRwyList(string id);
+	bool RemoveFromTrafficList(const string& id);
+	bool RemoveFromAppList(const string& id);
+	bool RemoveFromRwyList(const string& id);
 	
 	// Return the ETA of plane no. list_pos (1-based) in the traffic list.
 	// i.e. list_pos = 1 implies next to use runway.
diff --git a/src/ATC/transmission.hxx b/src/ATC/transmission.hxx
index 9c2cfd7c5..fafc885b7 100644
--- a/src/ATC/transmission.hxx
+++ b/src/ATC/transmission.hxx
@@ -95,9 +95,9 @@ public:
   void Init();
 
   inline atc_type  get_station()   const { return StationType; }
-  inline TransCode get_code()      { return Code; }
-  inline string    get_transtext() { return TransText; }
-  inline string    get_menutext()  { return MenuText; }
+  inline const TransCode& get_code()      { return Code; }
+  inline const string&    get_transtext() { return TransText; }
+  inline const string&    get_menutext()  { return MenuText; }
 
   // Return the parsed logic of the transmission  
   TransPar Parse();
diff --git a/src/ATC/transmissionlist.cxx b/src/ATC/transmissionlist.cxx
index 97eee3c01..2f138edc9 100644
--- a/src/ATC/transmissionlist.cxx
+++ b/src/ATC/transmissionlist.cxx
@@ -54,7 +54,7 @@ FGTransmissionList::~FGTransmissionList( void ) {
 
 
 // load default.transmissions
-bool FGTransmissionList::init( SGPath path ) {
+bool FGTransmissionList::init( const SGPath& path ) {
     FGTransmission a;
 
     transmissionlist_station.erase( transmissionlist_station.begin(), transmissionlist_station.end() );
diff --git a/src/ATC/transmissionlist.hxx b/src/ATC/transmissionlist.hxx
index 6ff15cbfa..c177d8f73 100644
--- a/src/ATC/transmissionlist.hxx
+++ b/src/ATC/transmissionlist.hxx
@@ -58,7 +58,7 @@ public:
   ~FGTransmissionList();
   
   // load the transmission data and build the map
-  bool init( SGPath path );
+  bool init( const SGPath& path );
   
   // query the database for the specified code,
   bool query_station( const atc_type &station, FGTransmission *a, int max_trans, int &num_trans );
diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx
index 5657a381f..dcba46e2c 100644
--- a/src/Airports/runways.cxx
+++ b/src/Airports/runways.cxx
@@ -43,14 +43,14 @@ SG_USING_STD(multimap);
 
 
 // add an entry to the list
-void FGRunwayList::add( const string id, const string rwy_no,
+void FGRunwayList::add( const string& id, const string& rwy_no,
                         const double longitude, const double latitude,
                         const double heading, const double length,
                         const double width,
                         const double displ_thresh1, const double displ_thresh2,
                         const double stopway1, const double stopway2,
-                        const string lighting_flags, const int surface_code,
-                        const string shoulder_code, const int marking_code,
+                        const string& lighting_flags, const int surface_code,
+                        const string& shoulder_code, const int marking_code,
                         const double smoothness, const bool dist_remaining )
 {
     FGRunway rwy;
@@ -93,7 +93,7 @@ void FGRunwayList::add( const string id, const string rwy_no,
 // Return reverse rwy number
 // eg 01 -> 19
 // 03L -> 21R
-static string GetReverseRunwayNo(string rwyno) {	
+static string GetReverseRunwayNo(string& rwyno) {	
     // cout << "Original rwyno = " << rwyNo << '\n';
     
     // standardize input number
diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx
index 5fd647811..b2fc35332 100644
--- a/src/Airports/runways.hxx
+++ b/src/Airports/runways.hxx
@@ -44,7 +44,7 @@ SG_USING_STD(multimap);
 
 
 struct ltstr {
-    bool operator()(const string s1, const string s2) const {
+    bool operator()(const string& s1, const string& s2) const {
         return s1 < s2;
     }
 };
@@ -94,13 +94,13 @@ public:
     ~FGRunwayList();
 
     // add an entry to the list
-    void add( const string id, const string rwy_no,
+    void add( const string& id, const string& rwy_no,
               const double longitude, const double latitude,
               const double heading, const double length, const double width,
               const double displ_thresh1, const double displ_thresh2,
               const double stopway1, const double stopway2,
-              const string lighting_flags, const int surface_code,
-              const string shoulder_code, const int marking_code,
+              const string& lighting_flags, const int surface_code,
+              const string& shoulder_code, const int marking_code,
               const double smoothness, const bool dist_remaining );
 
     // search for the specified apt id.
diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx
index 8cdd2e763..aa9ff14d8 100644
--- a/src/Airports/simple.cxx
+++ b/src/Airports/simple.cxx
@@ -128,8 +128,8 @@ string ScheduleTime::getName(time_t dayStart)
   	}
       //couldn't find one so return 0;
       //cerr << "Returning 0 " << endl;
-      return string(0);
     }
+    return string(0);
 }			      
 /******************************************************************************
  * RunwayList
@@ -151,7 +151,7 @@ RunwayList& RunwayList::operator= (const RunwayList &other)
     preferredRunways.push_back(*i);
   return *this;
 }
-void RunwayList::set(string tp, string lst)
+void RunwayList::set(const string &tp, const string &lst)
 {
   //weekday          = atoi(timeCopy.substr(0,1).c_str());
   //    timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
@@ -205,7 +205,7 @@ RunwayGroup& RunwayGroup:: operator= (const RunwayGroup &other)
   return *this;
 }
 
-void RunwayGroup::setActive(string aptId, 
+void RunwayGroup::setActive(const string &aptId, 
 			    double windSpeed, 
 			    double windHeading, 
 			    double maxTail, 
@@ -335,7 +335,7 @@ void RunwayGroup::setActive(string aptId,
 
 }
 
-void RunwayGroup::getActive(int i, string *name, string *type)
+void RunwayGroup::getActive(int i, string &name, string &type)
 {
   if (i == -1)
     {
@@ -343,13 +343,13 @@ void RunwayGroup::getActive(int i, string *name, string *type)
     }
   if (nrActive == (int)rwyList.size())
     {
-      *name = rwyList[i].getRwyList(active);
-      *type = rwyList[i].getType();
+      name = rwyList[i].getRwyList(active);
+      type = rwyList[i].getType();
     }
   else
     { 
-      *name = rwyList[choice[i]].getRwyList(active);
-      *type = rwyList[choice[i]].getType();
+      name = rwyList[choice[i]].getRwyList(active);
+      type = rwyList[choice[i]].getType();
     }
 }
 /*****************************************************************************
@@ -413,7 +413,7 @@ ScheduleTime *FGRunwayPreference::getSchedule(const char *trafficType)
   return 0;
 }
 
-RunwayGroup *FGRunwayPreference::getGroup(const string groupName)
+RunwayGroup *FGRunwayPreference::getGroup(const string &groupName)
 {
   PreferenceListIterator i = preferences.begin();
   if (preferences.begin() == preferences.end())
@@ -492,7 +492,7 @@ void  FGRunwayPreference::startElement (const char * name, const XMLAttributes &
 }
 
 //based on a string containing hour and minute, return nr seconds since day start.
-time_t FGRunwayPreference::processTime(string tme)
+time_t FGRunwayPreference::processTime(const string &tme)
 {
   string hour   = tme.substr(0, tme.find(":",0));
   string minute = tme.substr(tme.find(":",0)+1, tme.length());
@@ -569,7 +569,7 @@ void  FGRunwayPreference::error (const char * message, int line, int column) {
 /*****************************************************************************
  * Helper function for parsing position string
  ****************************************************************************/
-double processPosition(string pos)
+double processPosition(const string &pos)
 {
   string prefix;
   string subs;
@@ -602,9 +602,9 @@ FGParking::FGParking(double lat,
 		     double hdg,
 		     double rad,
 		     int idx,
-		     string name,
-		     string tpe,
-		     string codes)
+		     const string &name,
+		     const string &tpe,
+		     const string &codes)
 {
   latitude     = lat;
   longitude    = lon;
@@ -655,7 +655,7 @@ FGAirport::FGAirport(const FGAirport& other)
     }
 }
 
-FGAirport::FGAirport(string id, double lon, double lat, double elev, string name, bool has_metar)
+FGAirport::FGAirport(const string &id, double lon, double lat, double elev, const string &name, bool has_metar)
 {
   _id = id;
   _longitude = lon;
@@ -688,7 +688,7 @@ void FGAirport::init()
   groundNetwork.init();
 }
 
-bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, string flType, string acType, string airline)
+bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, const string &flType, const string &acType, const string &airline)
 {
   bool found = false;
   bool available = false;
@@ -1019,13 +1019,13 @@ void  FGAirport::error (const char * message, int line, int column) {
        << endl;
 }
 
-void FGAirport::setRwyUse(FGRunwayPreference& ref)
+void FGAirport::setRwyUse(const FGRunwayPreference& ref)
 {
   rwyPrefs = ref;
   //cerr << "Exiting due to not implemented yet" << endl;
   //exit(1);
 }
-void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
+void FGAirport::getActiveRunway(const string &trafficType, int action, string &runway)
 {
   double windSpeed;
   double windHeading;
@@ -1036,7 +1036,7 @@ void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
 
   if (!(rwyPrefs.available()))
     {
-      chooseRunwayFallback(runway);
+      runway = chooseRunwayFallback();
       return; // generic fall back goes here
     }
   else
@@ -1137,7 +1137,7 @@ void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
 	  for (int i = 0; i < nrActiveRunways; i++)
 	    {
 	      type = "unknown"; // initialize to something other than landing or takeoff
-	      currRunwayGroup->getActive(i, &name, &type);
+	      currRunwayGroup->getActive(i, name, type);
 	      if (type == "landing")
 		{
 		  landing.push_back(name);
@@ -1155,11 +1155,11 @@ void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
 	  int nr = takeoff.size();
 	  if (nr)
 	    {
-	      *runway = takeoff[(rand() %  nr)];
+	      runway = takeoff[(rand() %  nr)];
 	    }
 	  else
 	    { // Fallback
-	      chooseRunwayFallback(runway);
+	      runway = chooseRunwayFallback();
 	    }
 	} 
       if (action == 2) // landing
@@ -1167,20 +1167,20 @@ void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
 	  int nr = landing.size();
 	  if (nr)
 	    {
-	      *runway = landing[(rand() % nr)];
+	      runway = landing[(rand() % nr)];
 	    }
 	  else
 	    {  //fallback
-	       chooseRunwayFallback(runway);
+	       runway = chooseRunwayFallback();
 	    }
 	}
       
-      //*runway = globals->get_runways()->search(_id, int(windHeading));
-      //cerr << "Seleceted runway: " << *runway << endl;
+      //runway = globals->get_runways()->search(_id, int(windHeading));
+      //cerr << "Seleceted runway: " << runway << endl;
     }
 }
 
-void FGAirport::chooseRunwayFallback(string *runway)
+string FGAirport::chooseRunwayFallback()
 {   
   FGEnvironment 
     stationweather = ((FGEnvironmentMgr *) globals->get_subsystem("environment"))
@@ -1195,8 +1195,7 @@ void FGAirport::chooseRunwayFallback(string *runway)
     //which is consistent with Flightgear's initial setup.
   }
   
-  *runway = globals->get_runways()->search(_id, int(windHeading));
-  return; // generic fall back goes here
+   return globals->get_runways()->search(_id, int(windHeading));
 }
 
 
@@ -1284,12 +1283,12 @@ FGGroundNetwork::FGGroundNetwork()
   hasNetwork = false;
 }
 
-void FGGroundNetwork::addSegment(FGTaxiSegment seg)
+void FGGroundNetwork::addSegment(const FGTaxiSegment &seg)
 {
   segments.push_back(seg);
 }
 
-void FGGroundNetwork::addNode(FGTaxiNode node)
+void FGGroundNetwork::addNode(const FGTaxiNode &node)
 {
   nodes.push_back(node);
 }
@@ -1517,9 +1516,9 @@ FGAirportList::~FGAirportList( void ) {
 
 
 // add an entry to the list
-void FGAirportList::add( const string id, const double longitude,
+void FGAirportList::add( const string &id, const double longitude,
                          const double latitude, const double elevation,
-                         const string name, const bool has_metar )
+                         const string &name, const bool has_metar )
 {
     FGRunwayPreference rwyPrefs;
     FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar);
diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx
index eea3c0ede..7645f5972 100644
--- a/src/Airports/simple.hxx
+++ b/src/Airports/simple.hxx
@@ -76,7 +76,7 @@ public:
   void clear();
   void addStartTime(time_t time)     { start.push_back(time);            };
   void addEndTime  (time_t time)     { end.  push_back(time);            };
-  void addScheduleName(string sched) { scheduleNames.push_back(sched);   };
+  void addScheduleName(const string& sched) { scheduleNames.push_back(sched);   };
   void setTailWind(double wnd)  { tailWind = wnd;                        };
   void setCrossWind(double wnd) { tailWind = wnd;                        };
 
@@ -97,7 +97,7 @@ public:
   RunwayList(const RunwayList &other);
   RunwayList& operator= (const RunwayList &other);
 
-  void set(string, string);
+  void set(const string&, const string&);
   void clear();
 
   string getType() { return type; };
@@ -128,10 +128,10 @@ public:
 
   void setName(string nm) { name = nm;                };
   void add(RunwayList list) { rwyList.push_back(list);};
-  void setActive(string aptId, double windSpeed, double windHeading, double maxTail, double maxCross);
+  void setActive(const string& aptId, double windSpeed, double windHeading, double maxTail, double maxCross);
 
   int getNrActiveRunways() { return nrActive;};
-  void getActive(int i, string *name, string *type);
+  void getActive(int i, string& name, string& type);
 
   string getName() { return name; };
   void clear() { rwyList.clear(); }; 
@@ -157,7 +157,7 @@ private:
   RunwayGroup rwyGroup;
   PreferenceList preferences;
 
-  time_t processTime(string);
+  time_t processTime(const string&);
   bool initialized;
 
 public:
@@ -166,7 +166,7 @@ public:
   
   FGRunwayPreference & operator= (const FGRunwayPreference &other);
   ScheduleTime *getSchedule(const char *trafficType);
-  RunwayGroup *getGroup(const string groupName);
+  RunwayGroup *getGroup(const string& groupName);
   bool available() { return initialized; };
 
  // Some overloaded virtual XMLVisitor members
@@ -180,7 +180,7 @@ public:
   virtual void error (const char * message, int line, int column);
 };
 
-double processPosition(string pos);
+double processPosition(const string& pos);
 
 class FGParking {
 private:
@@ -205,17 +205,17 @@ public:
 	    double hdg,
 	    double rad,
 	    int idx,
-	    string name,
-	    string tpe,
-	    string codes);
-  void setLatitude (string lat)  { latitude    = processPosition(lat);  };
-  void setLongitude(string lon)  { longitude   = processPosition(lon);  };
+	    const string& name,
+	    const string& tpe,
+	    const string& codes);
+  void setLatitude (const string& lat)  { latitude    = processPosition(lat);  };
+  void setLongitude(const string& lon)  { longitude   = processPosition(lon);  };
   void setHeading  (double hdg)  { heading     = hdg;  };
   void setRadius   (double rad)  { radius      = rad;  };
   void setIndex    (int    idx)  { index       = idx;  };
-  void setName     (string name) { parkingName = name; };
-  void setType     (string tpe)  { type        = tpe;  };
-  void setCodes    (string codes){ airlineCodes= codes;};
+  void setName     (const string& name) { parkingName = name; };
+  void setType     (const string& tpe)  { type        = tpe;  };
+  void setCodes    (const string& codes){ airlineCodes= codes;};
 
   bool isAvailable ()         { return available;};
   void setAvailable(bool val) { available = val; };
@@ -261,8 +261,8 @@ public:
   void setIndex(int idx)                  { index = idx;};
   void setLatitude (double val)           { lat = val;};
   void setLongitude(double val)           { lon = val;};
-  void setLatitude (string val)           { lat = processPosition(val);  };
-  void setLongitude(string val)           { lon = processPosition(val);  };
+  void setLatitude (const string& val)           { lat = processPosition(val);  };
+  void setLongitude(const string& val)           { lon = processPosition(val);  };
   void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
   
   double getLatitude() { return lat;};
@@ -352,9 +352,9 @@ private:
 public:
   FGGroundNetwork();
 
-  void addNode   (FGTaxiNode node);
+  void addNode   (const FGTaxiNode& node);
   void addNodes  (FGParkingVec *parkings);
-  void addSegment(FGTaxiSegment seg); 
+  void addSegment(const FGTaxiSegment& seg); 
 
   void init();
   bool exists() { return hasNetwork; };
@@ -393,17 +393,18 @@ private:
   double avWindHeading [10];
   double avWindSpeed   [10];
 
+  string chooseRunwayFallback();
+
 public:
   FGAirport();
   FGAirport(const FGAirport &other);
   //operator= (FGAirport &other);
-  FGAirport(string id, double lon, double lat, double elev, string name, bool has_metar);
+  FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar);
 
   void init();
-  void getActiveRunway(string trafficType, int action, string *runway);
-  void chooseRunwayFallback(string *runway);
-  bool getAvailableParking(double *lat, double *lon, double *heading, int *gate, double rad, string fltype, 
-			   string acType, string airline);
+  void getActiveRunway(const string& trafficType, int action, string& runway);
+  bool getAvailableParking(double *lat, double *lon, double *heading, int *gate, double rad, const string& fltype, 
+			   const string& acType, const string& airline);
   void getParking         (int id, double *lat, double* lon, double *heading);
   FGParking *getParking(int i); // { if (i < parkings.size()) return parkings[i]; else return 0;};
   void releaseParking(int id);
@@ -422,10 +423,10 @@ public:
  FGGroundNetwork* getGroundNetwork() { return &groundNetwork; };
   
 
-  void setId(string id) { _id = id;};
+  void setId(const string& id) { _id = id;};
   void setMetar(bool value) { _has_metar = value; };
 
-  void setRwyUse(FGRunwayPreference& ref);
+  void setRwyUse(const FGRunwayPreference& ref);
 
  // Some overloaded virtual XMLVisitor members
   virtual void startXML (); 
@@ -462,8 +463,8 @@ public:
     ~FGAirportList();
 
     // add an entry to the list
-    void add( const string id, const double longitude, const double latitude,
-              const double elevation, const string name, const bool has_metar );
+    void add( const string& id, const double longitude, const double latitude,
+              const double elevation, const string& name, const bool has_metar );
 
     // search for the specified id.
       // Returns NULL if unsucessfull.
diff --git a/src/Autopilot/auto_gui.cxx b/src/Autopilot/auto_gui.cxx
index c42fc3812..42343865d 100644
--- a/src/Autopilot/auto_gui.cxx
+++ b/src/Autopilot/auto_gui.cxx
@@ -642,7 +642,7 @@ void TgtAptDialog_OK (puObject *)
 
 /* add new waypoint (either from above popup window 'ok button or telnet session) */
 
-int NewWaypoint( string Tgt_Alt )
+int NewWaypoint( const string& Tgt_Alt )
 {
   string TgtAptId;
   FGAirport a;
diff --git a/src/Autopilot/auto_gui.hxx b/src/Autopilot/auto_gui.hxx
index 9d9247d8e..69e455d4e 100644
--- a/src/Autopilot/auto_gui.hxx
+++ b/src/Autopilot/auto_gui.hxx
@@ -49,7 +49,7 @@ void fgAPAdjustInit() ;
 void NewHeadingInit();
 void NewAltitudeInit();
 
-int NewWaypoint( string Tgt_Alt );
+int NewWaypoint( const string& Tgt_Alt );
 
 
 #endif // _AUTO_GUI_HXX
diff --git a/src/Autopilot/route_mgr.hxx b/src/Autopilot/route_mgr.hxx
index 21e095086..2ab4df22b 100644
--- a/src/Autopilot/route_mgr.hxx
+++ b/src/Autopilot/route_mgr.hxx
@@ -90,7 +90,7 @@ public:
 
     bool build ();
 
-    void add_waypoint( SGWayPoint wp ) {
+    void add_waypoint( const SGWayPoint& wp ) {
         route->add_waypoint( wp );
     }
 
diff --git a/src/Autopilot/xmlauto.hxx b/src/Autopilot/xmlauto.hxx
index ded921924..26a92da82 100644
--- a/src/Autopilot/xmlauto.hxx
+++ b/src/Autopilot/xmlauto.hxx
@@ -78,9 +78,9 @@ public:
 
     virtual ~FGXMLAutoComponent() {}
 
-    virtual void update (double dt) {}
+    virtual void update (double dt)=0;
     
-    inline string get_name() { return name; }
+    inline const string& get_name() { return name; }
 };
 
 
diff --git a/src/Cockpit/built_in/FGMagRibbon.cxx b/src/Cockpit/built_in/FGMagRibbon.cxx
index 30c35d49a..7f0b64342 100644
--- a/src/Cockpit/built_in/FGMagRibbon.cxx
+++ b/src/Cockpit/built_in/FGMagRibbon.cxx
@@ -65,7 +65,7 @@ FGMagRibbon::draw ()
 				// Adjust to put the number in the centre
   xoffset -= 0.25;
 
-  FGCroppedTexture &t = getTexture();
+  FGCroppedTexture t = getTexture();
   t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
 
   glPushAttrib(GL_DEPTH_BUFFER_BIT);
diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx
index c9cfbd16e..89c3abd0b 100644
--- a/src/Cockpit/hud.hxx
+++ b/src/Cockpit/hud.hxx
@@ -251,7 +251,7 @@ public:
 
     ~fgLineSeg2D() {}
     
-    void draw()
+    void draw() const
     {
         glVertex2f(x0, y0);
         glVertex2f(x1, y1);
@@ -260,7 +260,7 @@ public:
 
 class DrawLineSeg2D {
     public:
-        void operator() (fgLineSeg2D elem) const {
+        void operator() (const fgLineSeg2D& elem) const {
             elem.draw();
         }
 };
@@ -375,7 +375,7 @@ class fgLineList {
 public:
     fgLineList( void ) {}
     ~fgLineList( void ) {}
-    void add( fgLineSeg2D seg ) { List.push_back(seg); }
+    void add( const fgLineSeg2D& seg ) { List.push_back(seg); }
     void erase( void ) { List.erase( List.begin(), List.end() ); }
     void draw( void ) {
         glBegin(GL_LINES);
@@ -392,7 +392,7 @@ public:
     ~fgTextList( void ) {}
     
     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
-    void add( fgText String ) { List.push_back(String); }
+    void add( const fgText& String ) { List.push_back(String); }
     void erase( void ) { List.erase( List.begin(), List.end() ); }
     
     void draw( void ) {
@@ -424,7 +424,7 @@ inline void Text( fgTextList &List, float x, float y, char *s)
     List.add( fgText( x, y, s) );
 }
 
-inline void Text( fgTextList &List, fgText &me)
+inline void Text( fgTextList &List, const fgText &me)
 {
     List.add(me);
 }
@@ -688,9 +688,9 @@ typedef lon_label * pLonlabel;
 class runway_instr : public instr_item 
 {
 private:	
-	void boundPoint(sgdVec3 v, sgdVec3 m);
-	bool boundOutsidePoints(sgdVec3 v, sgdVec3 m);
-	bool drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 p1, sgdVec3 p2);
+	void boundPoint(const sgdVec3& v, sgdVec3& m);
+	bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
+	bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
 	void drawArrow();
 	bool get_active_runway(FGRunway& rwy);
 	void get_rwy_points(sgdVec3 *points);
@@ -974,7 +974,7 @@ private:
     fgLineList         StippleLineList;
 
 public:
-    HudLadder( string    name,
+    HudLadder( const string&    name,
 	       int       x,
                int       y,
                UINT      width,
diff --git a/src/Cockpit/hud_ladr.cxx b/src/Cockpit/hud_ladr.cxx
index 974475f26..6c070b605 100644
--- a/src/Cockpit/hud_ladr.cxx
+++ b/src/Cockpit/hud_ladr.cxx
@@ -1,11 +1,13 @@
 
+#include <simgear/constants.h>
+
 #include "hud.hxx"
 #include "panel.hxx"
 
 #define DO_PANEL_HACK
 
 //====================== Top of HudLadder Class =======================
-HudLadder ::   HudLadder(  string name,
+HudLadder ::   HudLadder(  const string& name,
 			   int       x,
 			   int       y,
 			   UINT      width,
@@ -292,8 +294,8 @@ void HudLadder :: draw( void )
 	//  velocity vector
 	glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
         for(count=0; count<50; count++) {             
-	    cosine = 6 * cos(count * 2 * SGD_PI/50.0); 
-            sine =   6 * sin(count * 2 * SGD_PI/50.0); 
+	    cosine = 6 * cos(count * SGD_2PI/50.0); 
+            sine =   6 * sin(count * SGD_2PI/50.0); 
             glVertex2f(cosine+vel_x, sine+vel_y);
 	}     
 	glEnd(); 
diff --git a/src/Cockpit/hud_rwy.cxx b/src/Cockpit/hud_rwy.cxx
index 2fd326a6f..c1a938a9f 100644
--- a/src/Cockpit/hud_rwy.cxx
+++ b/src/Cockpit/hud_rwy.cxx
@@ -193,7 +193,7 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d) {
 	center = currentCenter;
 }
 
-bool runway_instr::drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 point1, sgdVec3 point2) {
+bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) {
 	sgdVec3 p1, p2;
 	sgdCopyVec3(p1, point1);
 	sgdCopyVec3(p2, point2);
@@ -254,7 +254,7 @@ bool runway_instr::drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 point1, sgdVec3 poin
     return (p1Valid && p2Valid);
 }
 
-void runway_instr::boundPoint(sgdVec3 v, sgdVec3 m) {
+void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
 	double y = v[1];
 	if(m[1] < v[1]) {
 		y = location.bottom;
@@ -279,7 +279,7 @@ void runway_instr::boundPoint(sgdVec3 v, sgdVec3 m) {
 	}
 }
 
-bool runway_instr::boundOutsidePoints(sgdVec3 v, sgdVec3 m) {
+bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
 	bool pointsInvalid = (v[1]>location.top && m[1]>location.top) ||
 		               (v[1]<location.bottom && m[1]<location.bottom) ||
 					   (v[0]>location.right && m[0]>location.right) ||
diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx
index 03e003c6c..d59c06f51 100644
--- a/src/Cockpit/panel.cxx
+++ b/src/Cockpit/panel.cxx
@@ -811,7 +811,7 @@ FGLayeredInstrument::addLayer (FGInstrumentLayer *layer)
 }
 
 int
-FGLayeredInstrument::addLayer (FGCroppedTexture &texture,
+FGLayeredInstrument::addLayer (const FGCroppedTexture &texture,
 			       int w, int h)
 {
   return addLayer(new FGTexturedLayer(texture, w, h));
diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx
index 46db96d30..221698106 100644
--- a/src/Cockpit/panel.hxx
+++ b/src/Cockpit/panel.hxx
@@ -417,7 +417,7 @@ public:
 
 				// Transfer pointer ownership!!
   virtual int addLayer (FGInstrumentLayer *layer);
-  virtual int addLayer (FGCroppedTexture &texture, int w = -1, int h = -1);
+  virtual int addLayer (const FGCroppedTexture &texture, int w = -1, int h = -1);
 
 				// Transfer pointer ownership!!
   virtual void addTransformation (FGPanelTransformation * transformation);
@@ -467,11 +467,10 @@ public:
   virtual void setTexture (const FGCroppedTexture &texture) {
     _texture = texture;
   }
-  virtual FGCroppedTexture &getTexture () { return _texture; }
   virtual const FGCroppedTexture &getTexture () const { return _texture; }
 
 private:
-  mutable FGCroppedTexture _texture;
+  FGCroppedTexture _texture;
 };
 
 
diff --git a/src/Environment/environment.cxx b/src/Environment/environment.cxx
index 10a1293bc..bd0f8039b 100644
--- a/src/Environment/environment.cxx
+++ b/src/Environment/environment.cxx
@@ -443,7 +443,7 @@ FGEnvironment::_recalc_hdgspd ()
   double angle_rad;
 
   if (wind_from_east_fps == 0) {
-    angle_rad = (wind_from_north_fps >= 0 ? SGD_PI/2 : -SGD_PI/2);
+    angle_rad = (wind_from_north_fps >= 0 ? SGD_PI_2 : -SGD_PI_2);
   } else {
     angle_rad = atan(wind_from_north_fps/wind_from_east_fps);
   }
diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx
index 551df9aa5..361ca423c 100644
--- a/src/Environment/environment_ctrl.cxx
+++ b/src/Environment/environment_ctrl.cxx
@@ -591,7 +591,7 @@ FGMetarEnvironmentCtrl::fetch_data( const string &icao )
 
 
 void
-FGMetarEnvironmentCtrl::update_metar_properties( FGMetar *m )
+FGMetarEnvironmentCtrl::update_metar_properties( const FGMetar *m )
 {
     int i;
     double d;
@@ -609,7 +609,7 @@ FGMetarEnvironmentCtrl::update_metar_properties( FGMetar *m )
     fgSetDouble("/environment/metar/max-visibility-m",
                 m->getMaxVisibility().getVisibility_m() );
 
-    SGMetarVisibility *dirvis = m->getDirVisibility();
+    const SGMetarVisibility *dirvis = m->getDirVisibility();
     for (i = 0; i < 8; i++, dirvis++) {
         const char *min = "/environment/metar/visibility[%d]/min-m";
         const char *max = "/environment/metar/visibility[%d]/max-m";
diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx
index a08c11a9a..61efc0756 100644
--- a/src/Environment/environment_ctrl.hxx
+++ b/src/Environment/environment_ctrl.hxx
@@ -64,7 +64,7 @@ public:
 
   virtual void setEnvironment (FGEnvironment * environment);
 
-  virtual FGEnvironment * getEnvironment () const { return _environment; }
+  virtual const FGEnvironment * getEnvironment () const { return _environment; }
 
   virtual void setLongitudeDeg (double lon_deg);
   virtual void setLatitudeDeg (double lat_deg);
@@ -180,7 +180,7 @@ private:
     SGPropertyNode *metar_max_age;
 
     FGMetarResult fetch_data( const string &icao );
-    virtual void update_metar_properties( FGMetar *m );
+    virtual void update_metar_properties( const FGMetar *m );
     void update_env_config();
 
 private:
diff --git a/src/Environment/fgclouds.cxx b/src/Environment/fgclouds.cxx
index b00ee64a9..9a5b51236 100644
--- a/src/Environment/fgclouds.cxx
+++ b/src/Environment/fgclouds.cxx
@@ -74,7 +74,7 @@ void FGClouds::init(void) {
 	}
 }
 
-SGNewCloud *FGClouds::buildCloud(SGPropertyNode *cloud_def_root, string name) {
+SGNewCloud *FGClouds::buildCloud(SGPropertyNode *cloud_def_root, const string& name) {
 	SGPropertyNode *cld_def=NULL;
 
 	cld_def = cloud_def_root->getChild(name.c_str());
@@ -103,7 +103,7 @@ SGNewCloud *FGClouds::buildCloud(SGPropertyNode *cloud_def_root, string name) {
 	return cld;
 }
 
-void FGClouds::buildLayer(SGCloudField *layer, string name, double alt, double coverage) {
+void FGClouds::buildLayer(SGCloudField *layer, const string& name, double alt, double coverage) {
 	struct {
 		string name;
 		double count;
@@ -275,7 +275,7 @@ FGClouds::update_metar_properties( FGMetar *m )
     fgSetDouble("/environment/metar/max-visibility-m",
                 m->getMaxVisibility().getVisibility_m() );
 
-    SGMetarVisibility *dirvis = m->getDirVisibility();
+    const SGMetarVisibility *dirvis = m->getDirVisibility();
     for (i = 0; i < 8; i++, dirvis++) {
         const char *min = "/environment/metar/visibility[%d]/min-m";
         const char *max = "/environment/metar/visibility[%d]/max-m";
@@ -378,7 +378,7 @@ FGClouds::update_env_config ()
 }
 
 
-void FGClouds::setLayer( int iLayer, float alt_ft, string coverage, string layer_type ) {
+void FGClouds::setLayer( int iLayer, float alt_ft, const string& coverage, const string& layer_type ) {
 	double coverage_norm = 0.0;
 	if( coverage == "few" )
 		coverage_norm = 2.0/8.0;	// <1-2
@@ -393,7 +393,7 @@ void FGClouds::setLayer( int iLayer, float alt_ft, string coverage, string layer
 	buildLayer(layer3D, layer_type, station_elevation_ft + alt_ft * SG_FEET_TO_METER, coverage_norm);
 }
 
-void FGClouds::buildScenario( string scenario ) {
+void FGClouds::buildScenario( const string& scenario ) {
 	string fakeMetar="";
 	string station = fgGetString("/environment/metar/station-id", "XXXX");
 
diff --git a/src/Environment/fgclouds.hxx b/src/Environment/fgclouds.hxx
index c078d0f01..e5840fbe1 100644
--- a/src/Environment/fgclouds.hxx
+++ b/src/Environment/fgclouds.hxx
@@ -42,14 +42,14 @@ class FGEnvironmentCtrl;
 class FGClouds {
 
 private:
-	SGNewCloud *buildCloud(SGPropertyNode *cloud_def_root, string name);
-	void buildLayer(SGCloudField *layer, string name, double alt, double coverage);
+	SGNewCloud *buildCloud(SGPropertyNode *cloud_def_root, const string& name);
+	void buildLayer(SGCloudField *layer, const string& name, double alt, double coverage);
 
 	void buildMETAR(void);
 
-	void buildScenario( string scenario );
+	void buildScenario( const string& scenario );
 
-	void setLayer( int iLayer, float alt_m, string coverage, string layer_type );
+	void setLayer( int iLayer, float alt_m, const string& coverage, const string& layer_type );
 
 	void update_metar_properties( FGMetar *m );
 
diff --git a/src/Instrumentation/kr_87.hxx b/src/Instrumentation/kr_87.hxx
index 0b6dd7aa5..a09d8c458 100644
--- a/src/Instrumentation/kr_87.hxx
+++ b/src/Instrumentation/kr_87.hxx
@@ -120,7 +120,7 @@ public:
     void search ();
 
     // internal values
-    inline string get_ident() const { return ident; }
+    inline const string& get_ident() const { return ident; }
     inline bool get_valid() const { return valid; }
     inline bool get_inrange() const { return inrange; }
     inline double get_stn_lon() const { return stn_lon; }
diff --git a/src/Instrumentation/tacan.cxx b/src/Instrumentation/tacan.cxx
index faa09a01f..279d33c4c 100755
--- a/src/Instrumentation/tacan.cxx
+++ b/src/Instrumentation/tacan.cxx
@@ -353,7 +353,7 @@ TACAN::search (double frequency_mhz, double longitude_rad,
 }
 
 double
-TACAN::searchChannel (string _channel){
+TACAN::searchChannel (const string& _channel){
     
     double frequency_khz = 0;
     
diff --git a/src/Instrumentation/tacan.hxx b/src/Instrumentation/tacan.hxx
index 017fe87d5..573f4b111 100755
--- a/src/Instrumentation/tacan.hxx
+++ b/src/Instrumentation/tacan.hxx
@@ -52,7 +52,7 @@ private:
 
     void search (double frequency, double longitude_rad,
                  double latitude_rad, double altitude_m);
-    double searchChannel (string _channel);
+    double searchChannel (const string& _channel);
 
     SGPropertyNode_ptr _longitude_node;
     SGPropertyNode_ptr _latitude_node;
diff --git a/src/Main/metar_main.cxx b/src/Main/metar_main.cxx
index 36567ffb3..96dae6f3d 100644
--- a/src/Main/metar_main.cxx
+++ b/src/Main/metar_main.cxx
@@ -27,6 +27,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/environment/metar.hxx>
 #include <simgear/structure/exception.hxx>
+#include <simgear/scene/sky/sky.hxx>
 
 using namespace std;
 
@@ -79,7 +80,7 @@ double rnd(double r, int g = 0)
 }
 
 
-ostream& operator<<(ostream& s, SGMetarVisibility& v)
+ostream& operator<<(ostream& s, const SGMetarVisibility& v)
 {
 	ostringstream buf;
 	int m = v.getModifier();
@@ -154,7 +155,7 @@ void printReport(SGMetar *m)
 
 
 	// directed visibility
-	SGMetarVisibility *dirvis = m->getDirVisibility();
+	const SGMetarVisibility *dirvis = m->getDirVisibility();
 	for (i = 0; i < 8; i++, dirvis++)
 		if (dirvis->getVisibility_m() != NaN)
 			cout << "\t\t\t" << *dirvis << endl;
@@ -484,6 +485,7 @@ void usage()
 	);
 }
 
+SGSky* thesky = new SGSky;
 
 int main(int argc, char *argv[])
 {
diff --git a/src/Navaids/fix.hxx b/src/Navaids/fix.hxx
index b4f9817ff..8de3e5e12 100644
--- a/src/Navaids/fix.hxx
+++ b/src/Navaids/fix.hxx
@@ -59,7 +59,7 @@ public:
     inline FGFix(void);
     inline ~FGFix(void) {}
 
-    inline string get_ident() const { return ident; }
+    inline const string& get_ident() const { return ident; }
     inline double get_lon() const { return lon; }
     inline double get_lat() const { return lat; }
 
diff --git a/src/Navaids/nav.hxx b/src/Navaids/nav.hxx
index a481959ee..c9ad715c9 100644
--- a/src/Navaids/nav.hxx
+++ b/src/Navaids/nav.hxx
@@ -63,7 +63,7 @@ public:
     inline FGNav();
     inline FGNav( int _type, double _lat, double _lon, double _elev_ft,
                   int _freq, double _range, double _magvar,
-                  string _ident, string _name,
+                  const string& _ident, const string& _name,
                   bool _serviceable );
     inline ~FGNav() {}
 
@@ -78,9 +78,9 @@ public:
     inline double get_range() const { return range; }
     // inline bool get_has_dme() const { return has_dme; }
     inline const char *get_ident() { return ident.c_str(); }
-    inline string get_trans_ident() { return trans_ident; }
+    inline const string& get_trans_ident() { return trans_ident; }
     inline double get_magvar() const { return magvar; }
-    inline string get_name() { return name; }
+    inline const string& get_name() { return name; }
 };
 
 
@@ -105,7 +105,7 @@ FGNav::FGNav() :
 inline
 FGNav::FGNav( int _type, double _lat, double _lon, double _elev_ft,
               int _freq, double _range, double _magvar,
-              string _ident, string _name,
+              const string& _ident, const string& _name,
               bool _serviceable ) :
     type(0),
     lon(0.0), lat(0.0),
diff --git a/src/Navaids/navlist.cxx b/src/Navaids/navlist.cxx
index c5234dea4..4b866580f 100644
--- a/src/Navaids/navlist.cxx
+++ b/src/Navaids/navlist.cxx
@@ -334,7 +334,7 @@ FGNavRecord *FGNavList::findClosest( double lon_rad, double lat_rad,
 }
 
 // Given a TACAN Channel return the first matching frequency
-FGTACANRecord *FGTACANList::findByChannel( string channel )
+FGTACANRecord *FGTACANList::findByChannel( const string& channel )
 {
     tacan_list_type stations = ident_channels[channel];
     SG_LOG( SG_INSTR, SG_DEBUG, "findByChannel " << channel<< " size " << stations.size()  );
diff --git a/src/Navaids/navlist.hxx b/src/Navaids/navlist.hxx
index be18ad291..705572aed 100644
--- a/src/Navaids/navlist.hxx
+++ b/src/Navaids/navlist.hxx
@@ -99,7 +99,7 @@ public:
     // given a frequency returns the first matching entry
     FGNavRecord *findStationByFreq( double frequency );
 
-    inline nav_map_type get_navaids() const { return navaids; }
+    inline const nav_map_type& get_navaids() const { return navaids; }
 };
 
 class FGTACANList {
@@ -128,7 +128,7 @@ public:
     bool add( FGTACANRecord *r );
     
     // Given a TACAN Channel, return the appropriate frequency.  
-    FGTACANRecord *findByChannel( string channel );
+    FGTACANRecord *findByChannel( const string& channel );
 
     
 };
diff --git a/src/Network/ray.cxx b/src/Network/ray.cxx
index e93dc3fc2..c4b0508ba 100644
--- a/src/Network/ray.cxx
+++ b/src/Network/ray.cxx
@@ -104,11 +104,11 @@ bool FGRAY::gen_message() {
 	/* Make sure the angles are reasonable onscale */
  	/* We use an asymmetric mapping so that the chair behaves
  	   reasonably when upside down.  Otherwise it oscillates. */
- 	while ( ang_pos < -2*SGD_PI/3 ) {
-		ang_pos += 2 * SGD_PI;
+ 	while ( ang_pos < -SGD_2PI/3 ) {
+		ang_pos += SGD_2PI;
 	}
- 	while ( ang_pos >  4*SGD_PI/3 ) {
-		ang_pos -= 2 * SGD_PI;
+ 	while ( ang_pos >  2*SGD_2PI/3 ) {
+		ang_pos -= SGD_2PI;
 	}
 
 	/* Tell interested parties what the situation is */
@@ -134,8 +134,8 @@ bool FGRAY::gen_message() {
 		if ( fabs ( ang_pos - chair_heading ) > SGD_PI )
 		{	/* Need to swing chair by 360 degrees */
 			if ( ang_pos < chair_heading )
-				chair_heading -= 2 * SGD_PI;
-			else	chair_heading += 2 * SGD_PI;
+				chair_heading -= SGD_2PI;
+			else	chair_heading +=  SGD_2PI;
 		}
 		/* Remove the chair heading from the true heading */
 		ang_pos -= chair_heading;
@@ -144,7 +144,7 @@ bool FGRAY::gen_message() {
  		   can just about represent 30 degrees full scale.  */
 		chair_heading += ang_pos * dt * 0.2;
 		/* If they turn fast, at 90 deg error subtract 30 deg */
-		if ( fabs(ang_pos) > SGD_PI / 2 )
+		if ( fabs(ang_pos) > SGD_PI_2 )
 			chair_heading += ang_pos / 3;
 
 	} else
@@ -178,8 +178,8 @@ bool FGRAY::gen_message() {
 		/* Scale to the hardware's full scale range */
 		propose /= fullscale [ subaxis ];
 		/* Use a sine shaped washout on all axes */
-		if ( propose < -SGD_PI / 2 ) *dac = 0x0000; else
-		if ( propose >  SGD_PI / 2 ) *dac = 0xFFFF; else
+		if ( propose < -SGD_PI_2 ) *dac = 0x0000; else
+		if ( propose >  SGD_PI_2 ) *dac = 0xFFFF; else
 		   *dac = (unsigned short) ( 32767 * 
 				( 1.0 + sin ( propose ) ) );
 	}
diff --git a/src/Scenery/scenery.cxx b/src/Scenery/scenery.cxx
index 51e26ae67..183826b27 100644
--- a/src/Scenery/scenery.cxx
+++ b/src/Scenery/scenery.cxx
@@ -100,7 +100,7 @@ void FGScenery::bind() {
 void FGScenery::unbind() {
 }
 
-void FGScenery::set_center( Point3D p ) {
+void FGScenery::set_center( const Point3D& p ) {
     center = p;
     sgdVec3 c;
     sgdSetVec3(c, p.x(), p.y(), p.z());
@@ -146,7 +146,7 @@ FGScenery::get_elevation_m(double lat, double lon, double max_alt,
 }
 
 bool
-FGScenery::get_cart_elevation_m(const sgdVec3 pos, double max_altoff,
+FGScenery::get_cart_elevation_m(const sgdVec3& pos, double max_altoff,
                                 double& alt, bool exact)
 {
   Point3D saved_center = center;
diff --git a/src/Scenery/scenery.hxx b/src/Scenery/scenery.hxx
index 847f2e3a4..eed0e67a0 100644
--- a/src/Scenery/scenery.hxx
+++ b/src/Scenery/scenery.hxx
@@ -105,14 +105,14 @@ public:
     /// lat/lon pair. If there is no scenery for that point, the altitude
     /// value is undefined.
     /// All values are meant to be in meters.
-    bool get_cart_elevation_m(const sgdVec3 pos, double max_altoff,
+    bool get_cart_elevation_m(const sgdVec3& pos, double max_altoff,
                               double& radius, bool exact = false);
 
-    inline Point3D get_center() const { return center; }
-    void set_center( Point3D p );
+    inline const Point3D& get_center() const { return center; }
+    void set_center( const Point3D& p );
 
-    inline Point3D get_next_center() const { return next_center; }
-    inline void set_next_center( Point3D p ) { next_center = p; }
+    inline const Point3D& get_next_center() const { return next_center; }
+    inline void set_next_center( const Point3D& p ) { next_center = p; }
 
     inline ssgRoot *get_scene_graph () const { return scene_graph; }
     inline void set_scene_graph (ssgRoot * s) { scene_graph = s; }
diff --git a/src/Scenery/tileentry.hxx b/src/Scenery/tileentry.hxx
index 90471243b..51d3d34d0 100644
--- a/src/Scenery/tileentry.hxx
+++ b/src/Scenery/tileentry.hxx
@@ -82,7 +82,7 @@ private:
 public:
 
     inline FGDeferredModel() { }
-    inline FGDeferredModel( const string mp, const string tp, SGBucket b,
+    inline FGDeferredModel( const string& mp, const string& tp, SGBucket b,
 		     FGTileEntry *t, ssgTransform *ot )
     {
 	model_path = mp;
@@ -92,9 +92,9 @@ public:
 	obj_trans = ot;
     }
     inline ~FGDeferredModel() { }
-    inline string get_model_path() const { return model_path; }
-    inline string get_texture_path() const { return texture_path; }
-    inline SGBucket get_bucket() const { return bucket; }
+    inline const string& get_model_path() const { return model_path; }
+    inline const string& get_texture_path() const { return texture_path; }
+    inline const SGBucket& get_bucket() const { return bucket; }
     inline FGTileEntry *get_tile() const { return tile; }
     inline ssgTransform *get_obj_trans() const { return obj_trans; }
 };
@@ -248,7 +248,7 @@ public:
     /**
      * Return the "bucket" for this tile
      */
-    inline SGBucket get_tile_bucket() const { return tile_bucket; }
+    inline const SGBucket& get_tile_bucket() const { return tile_bucket; }
 
     /**
      * Apply ssgLeaf::makeDList to all leaf of a branch
diff --git a/src/Server/messagebuf.cxx b/src/Server/messagebuf.cxx
index b63509e25..1cb937b47 100644
--- a/src/Server/messagebuf.cxx
+++ b/src/Server/messagebuf.cxx
@@ -70,7 +70,7 @@ void FGMPSMessageBuf::writed(double data)
 	write8(&data);
 }
 
-void FGMPSMessageBuf::writes(string data)
+void FGMPSMessageBuf::writes(const string& data)
 {
 	put(data.length());
 	for (int i=0; i<data.length(); i++) put(data[i]);
diff --git a/src/Server/messagebuf.hxx b/src/Server/messagebuf.hxx
index c905f8b2b..83fa1ace6 100644
--- a/src/Server/messagebuf.hxx
+++ b/src/Server/messagebuf.hxx
@@ -49,20 +49,20 @@ private:
 public:
 
 	FGMPSMessageBuf()		{ init(""); }
-	FGMPSMessageBuf(string data)	{ init(data); }
+	FGMPSMessageBuf(const string& data)	{ init(data); }
 
 	~FGMPSMessageBuf() {}
 
-	void init(string data)
+	void init(const string& data)
 	{
 		buf = data;
 		pos = 0;
 	}
 
 	void	clr()			{ buf = ""; }
-	void	add(string data)	{ buf += data; }
-	void	set(string data)	{ buf = data; }
-	string&	str()			{ return buf; }
+	void	add(const string& data)	{ buf += data; }
+	void	set(const string& data)	{ buf = data; }
+	const string&	str()		{ return buf; }
 	size_t	ofs()			{ return pos; }
 	void	ofs(size_t val)		{ pos = val; }
 
@@ -86,7 +86,7 @@ public:
 	double	readd();
 	string	reads(size_t length);
 
-	string&	buffer() { return buf; }
+	const string&	buffer() { return buf; }
 };
 
 #endif
diff --git a/src/Sound/morse.cxx b/src/Sound/morse.cxx
index ea86999d8..f018334e2 100644
--- a/src/Sound/morse.cxx
+++ b/src/Sound/morse.cxx
@@ -87,7 +87,7 @@ void make_tone( unsigned char *buf, int freq,
     int i, j;
 
     for ( i = 0; i < trans_len; ++i ) {
-	float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+	float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
 	    * ((double)i / trans_len) / 2.0 + 0.5;
 
 	/* Convert to unsigned byte */
@@ -95,7 +95,7 @@ void make_tone( unsigned char *buf, int freq,
     }
 
     for ( i = trans_len; i < len - trans_len; ++i ) {
-	float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+	float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
 	    / 2.0 + 0.5;
 
 	/* Convert to unsigned byte */
@@ -103,7 +103,7 @@ void make_tone( unsigned char *buf, int freq,
     }
     j = trans_len;
     for ( i = len - trans_len; i < len; ++i ) {
-	float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
+	float level = ( sin( (double) i * SGD_2PI / (BYTES_PER_SECOND / freq) ) )
 	    * ((double)j / trans_len) / 2.0 + 0.5;
 	--j;
 
diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx
index 0fb30bf41..7959785fb 100644
--- a/src/Systems/electrical.hxx
+++ b/src/Systems/electrical.hxx
@@ -81,7 +81,7 @@ public:
     FGElectricalComponent();
     virtual ~FGElectricalComponent() {}
 
-    inline string get_name() { return name; }
+    inline const string& get_name() { return name; }
 
     inline int get_kind() const { return kind; }
 
@@ -111,7 +111,7 @@ public:
     }
 
     inline int get_num_props() const { return props.size(); }
-    inline string get_prop( const int i ) {
+    inline const string& get_prop( const int i ) {
         return props[i];
     }
     inline void add_prop( const string &s ) {
diff --git a/src/Time/light.cxx b/src/Time/light.cxx
index a0605f7d1..5eb4f2c17 100644
--- a/src/Time/light.cxx
+++ b/src/Time/light.cxx
@@ -44,9 +44,6 @@
 #  include <math.h>
 #endif
 
-#include <string>
-SG_USING_STD(string);
-
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/interpolater.hxx>
diff --git a/src/Time/light.hxx b/src/Time/light.hxx
index b3a171c56..5c782d775 100644
--- a/src/Time/light.hxx
+++ b/src/Time/light.hxx
@@ -149,8 +149,8 @@ public:
     inline double get_sun_gc_lat () const { return _sun_gc_lat; }
     inline void set_sun_gc_lat (double l) { _sun_gc_lat = l; }
 
-    inline Point3D get_sunpos () const { return _sunpos; }
-    inline void set_sunpos (Point3D p) { _sunpos = p; }
+    inline const Point3D& get_sunpos () const { return _sunpos; }
+    inline void set_sunpos (const Point3D& p) { _sunpos = p; }
 
     inline float *sun_vec () const { return (float *)_sun_vec; }
     inline float *sun_vec_inv () const { return (float *)_sun_vec_inv; }
@@ -170,8 +170,8 @@ public:
     inline double get_moon_gc_lat () const { return _moon_gc_lat; }
     inline void set_moon_gc_lat (double l) { _moon_gc_lat = l; }
 
-    inline Point3D get_moonpos () const { return _moonpos; }
-    inline void set_moonpos (Point3D p) { _moonpos = p; }
+    inline const Point3D& get_moonpos () const { return _moonpos; }
+    inline void set_moonpos (const Point3D& p) { _moonpos = p; }
 
     inline float *moon_vec () const { return (float *)_moon_vec; }
     inline float *moon_vec_inv () const { return (float *)_moon_vec_inv; }
diff --git a/src/Traffic/SchedFlight.cxx b/src/Traffic/SchedFlight.cxx
index 4a86c98c4..a65adad8c 100644
--- a/src/Traffic/SchedFlight.cxx
+++ b/src/Traffic/SchedFlight.cxx
@@ -91,14 +91,14 @@ FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)
   initialized     = other.initialized;
 }
 
-FGScheduledFlight::FGScheduledFlight(string cs,
-		   string fr,
-		   string depPrt,
-		   string arrPrt,
+FGScheduledFlight::FGScheduledFlight(const string& cs,
+		   const string& fr,
+		   const string& depPrt,
+		   const string& arrPrt,
 		   int cruiseAlt,
-		   string deptime,
-		   string arrtime,
-		   string rep)
+		   const string& deptime,
+		   const string& arrtime,
+		   const string& rep)
 {
   callsign          = cs;
   fltRules          = fr;
@@ -142,7 +142,7 @@ FGScheduledFlight:: ~FGScheduledFlight()
 {
 }
 
-time_t FGScheduledFlight::processTimeString(string theTime)
+time_t FGScheduledFlight::processTimeString(const string& theTime)
 {
   int weekday;
   int timeOffsetInDays;
diff --git a/src/Traffic/SchedFlight.hxx b/src/Traffic/SchedFlight.hxx
index 2396ae84b..b6541bd46 100644
--- a/src/Traffic/SchedFlight.hxx
+++ b/src/Traffic/SchedFlight.hxx
@@ -67,14 +67,14 @@ public:
   FGScheduledFlight();
   FGScheduledFlight(const FGScheduledFlight &other);
   //  FGScheduledFlight(const string);
-  FGScheduledFlight::FGScheduledFlight(string cs,
-		     string fr,
-		     string depPrt,
-		     string arrPrt,
+  FGScheduledFlight::FGScheduledFlight(const string& cs,
+		     const string& fr,
+		     const string& depPrt,
+		     const string& arrPrt,
 		     int cruiseAlt,
-		     string deptime,
-		     string arrtime,
-		     string rep
+		     const string& deptime,
+		     const string& arrtime,
+		     const string& rep
 		     );
   ~FGScheduledFlight();
 
@@ -96,8 +96,8 @@ public:
     return (departureTime < other.departureTime); 
   };
 
-  time_t processTimeString(string time);
-  string getCallSign() {return callsign; };
+  time_t processTimeString(const string& time);
+  const string& getCallSign() {return callsign; };
 };
 
 typedef vector<FGScheduledFlight>           FGScheduledFlightVec;
diff --git a/src/Traffic/Schedule.hxx b/src/Traffic/Schedule.hxx
index b099bd08c..315969042 100644
--- a/src/Traffic/Schedule.hxx
+++ b/src/Traffic/Schedule.hxx
@@ -73,11 +73,11 @@ class FGAISchedule
   int         getCruiseAlt        () { return flights.begin()->getCruiseAlt       (); };
   double      getRadius           () { return radius; };
   double      getGroundOffset     () { return groundOffset;};
-  string      getFlightType       () { return flightType;};
-  string      getAirline          () { return airline; };
-  string      getAircraft         () { return acType; };
-  string      getCallSign         () { return flights.begin()->getCallSign (); };
-  string      getRegistration     () { return registration;};
+  const string& getFlightType     () { return flightType;};
+  const string& getAirline        () { return airline; };
+  const string& getAircraft       () { return acType; };
+  const string& getCallSign       () { return flights.begin()->getCallSign (); };
+  const string& getRegistration   () { return registration;};
   bool getHeavy                   () { return heavy; };
   bool operator< (const FGAISchedule &other) const { return (distanceToUser < other.distanceToUser); };
   //void * getAiRef                 () { return AIManagerRef; };