diff --git a/src/BuildTiles/Main/tgconstruct_output.cxx b/src/BuildTiles/Main/tgconstruct_output.cxx
index a54bc731..296e2aa9 100644
--- a/src/BuildTiles/Main/tgconstruct_output.cxx
+++ b/src/BuildTiles/Main/tgconstruct_output.cxx
@@ -99,9 +99,12 @@ void TGConstruct::AddCustomObjects( void ) {
                         string command = "cp " + basecom + " " + dest_dir;
 #endif
                         SG_LOG( SG_GENERAL, SG_DEBUG, "running " << command );
-                        system( command.c_str() );
-
-                        fprintf(fp, "OBJECT %s\n", name);
+                        
+                        if ( system( command.c_str() ) != -1 ) {
+                            fprintf(fp, "OBJECT %s\n", name);
+                        } else {
+                            SG_LOG( SG_GENERAL, SG_ALERT, "Could not issue command " << command ); 
+                        }
                     } else {
                         fprintf(fp, "%s\n", line);
                     }
diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx
index f691bcce..d07fafa8 100644
--- a/src/BuildTiles/Parallel/client.cxx
+++ b/src/BuildTiles/Parallel/client.cxx
@@ -277,27 +277,31 @@ bool construct_tile( const SGBucket& b,
     command = command + " > " + result_file + " 2>&1";
     cout << command << endl;
 	
-    system( command.c_str() );
-	
-    FILE *fp = fopen( result_file.c_str(), "r" );
-    if ( fp == NULL) {
-	cout << "Missing results file " << result_file << endl;
-	return false;
-    }
-    char line[256];
-    while ( fgets( line, 256, fp ) != NULL ) {
-        string line_str = line;
-        line_str = line_str.substr(0, line_str.length() - 1);
-        // cout << line_str << endl;
-        if ( line_str == "[Finished successfully]" ) {
-            cout << "Tile " << b.gen_index_str() << " finished successfully" << endl;
-            fclose(fp);
-            return true;
+    if ( system( command.c_str() ) != -1 ) {
+        FILE *fp = fopen( result_file.c_str(), "r" );
+        if ( fp == NULL) {
+            cout << "Missing results file " << result_file << endl;
+            return false;
+        } else {
+            char line[256];
+            while ( fgets( line, 256, fp ) != NULL ) {
+                string line_str = line;
+                line_str = line_str.substr(0, line_str.length() - 1);
+                // cout << line_str << endl;
+                if ( line_str == "[Finished successfully]" ) {
+                    cout << "Tile " << b.gen_index_str() << " finished successfully" << endl;
+                    fclose(fp);
+                    return true;
+                }
+                
+            }
+            fclose(fp);            
         }
-
+    } else {
+        cout << "Could not issue command " << command << endl;
+        return false;        
     }
-    fclose(fp);
-    
+        
     // Save the log file of the failed tile
     cout << "Tile " << b.gen_index_str() << " failed" << endl;
     string savelog=work_base+"/Status/failed-"+b.gen_index_str()+".log";
@@ -305,8 +309,11 @@ bool construct_tile( const SGBucket& b,
     command="mv "+result_file+" " +savelog;
     cout << command << endl;
     
-    system(command.c_str());
-    
+    if ( system(command.c_str()) == -1 ) {
+        cout << "Could not issue command " << command << endl;
+        return false;        
+    }
+        
     return false;
 }
 
diff --git a/src/BuildTiles/Parallel/server.cxx b/src/BuildTiles/Parallel/server.cxx
index 8759fce9..afdb0b15 100644
--- a/src/BuildTiles/Parallel/server.cxx
+++ b/src/BuildTiles/Parallel/server.cxx
@@ -267,7 +267,9 @@ void log_pending_tile( const string& path, long int tile ) {
     string pending_file = path + "/" + b.gen_index_str() + ".pending";
 
     string command = "touch " + pending_file;
-    system( command.c_str() );
+    if ( system( command.c_str() ) == -1 ) {
+        cout << "Could not issue command " << command << endl;
+    }    
 }
 
 
@@ -288,7 +290,10 @@ void log_failed_tile( const string& path, long int tile ) {
     string failed_file = path + "/" + b.gen_index_str() + ".failed";
 
     string command = "touch " + failed_file;
-    system( command.c_str() );
+    
+    if ( system( command.c_str() ) == -1 ) {
+        cout << "Could not issue command " << command << endl;
+    }
 
     cout << "logged bad tile = " << tile << endl;
 }
diff --git a/src/Lib/DEM/dem.cxx b/src/Lib/DEM/dem.cxx
index a30dce23..ab372df7 100644
--- a/src/Lib/DEM/dem.cxx
+++ b/src/Lib/DEM/dem.cxx
@@ -187,8 +187,8 @@ TGDem::read_a_record() {
 
     // Map projection parameters (ignored)
     for ( i = 0; i < 15; i++ ) {
-	dnum = next_exp();
-	// printf("%d: %f\n",i,dnum);
+        dnum = next_exp();
+        SG_LOG(SG_GENERAL, SG_DEBUG, i << ": "  << dnum);
     }
 
     // Units code, 3 represents arc-seconds as the unit of measure for
diff --git a/src/Lib/HGT/hgt.cxx b/src/Lib/HGT/hgt.cxx
index fcf4198a..5da4a194 100644
--- a/src/Lib/HGT/hgt.cxx
+++ b/src/Lib/HGT/hgt.cxx
@@ -40,11 +40,13 @@
 #  include <direct.h>
 #endif
 
+#include <boost/foreach.hpp>
+
 #include <simgear/constants.h>
 #include <simgear/io/lowlevel.hxx>
 #include <simgear/misc/sg_dir.hxx>
+#include <simgear/debug/logstream.hxx>
 
-#include <boost/foreach.hpp>
 
 #include "hgt.hxx"
 
@@ -92,19 +94,23 @@ TGHgt::open ( const SGPath &f ) {
             
             cout << "Extracting " << file_name.str() << " to " << tmp_dir.path().str() << endl;
             string command = "unzip -d \"" + tmp_dir.path().str() + "\" " + file_name.base();
-            system( command.c_str() );
-
-            simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
-            BOOST_FOREACH(const SGPath& file, files) {
-                string ext = file.lower_extension();
-                if ( ext == "hgt" ) {
-                    file_name = file;
-                    break;
+            if ( system( command.c_str() ) != -1 )
+            {
+                simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
+                BOOST_FOREACH(const SGPath& file, files) {
+                    string ext = file.lower_extension();
+                    if ( ext == "hgt" ) {
+                        file_name = file;
+                        break;
+                    }
                 }
-            }
             
-            remove_tmp_file = true;
-            cout << "Proceeding with " << file_name.str() << endl;
+                remove_tmp_file = true;
+                cout << "Proceeding with " << file_name.str() << endl;
+            } else {
+                SG_LOG(SG_GENERAL, SG_ALERT, "Failed to issue system call " << command );
+                exit(1);
+            }
         }
 
         cout << "Loading HGT data file: " << file_name.str() << endl;
diff --git a/src/Lib/terragear/tg_chopper.cxx b/src/Lib/terragear/tg_chopper.cxx
index f36800b0..6ef3b4e7 100644
--- a/src/Lib/terragear/tg_chopper.cxx
+++ b/src/Lib/terragear/tg_chopper.cxx
@@ -154,7 +154,12 @@ long int tgChopper::GenerateIndex( std::string path )
                 exit( 0 );
             }
         } else {
-            fread( (void*)&index, sizeof(long int), 1, fp );
+            if ( fread( (void*)&index, sizeof(long int), 1, fp ) != 1 )
+            {
+                SG_LOG(SG_GENERAL, SG_ALERT, "Error reading Index file " << index_file << " abort");
+                boost::interprocess::named_mutex::remove("tgChopper_index2");
+                exit(0);
+            }
         }
 
         index++;
diff --git a/src/Lib/terragear/tg_misc.cxx b/src/Lib/terragear/tg_misc.cxx
index 79ae0a84..2931607d 100644
--- a/src/Lib/terragear/tg_misc.cxx
+++ b/src/Lib/terragear/tg_misc.cxx
@@ -10,13 +10,8 @@
 
 const double isEqual2D_Epsilon = 0.000001;
 
-#if 0
 #define CLIPPER_FIXEDPT           (1000000000000)
 #define CLIPPER_METERS_PER_DEGREE (111000)
-#else
-#define CLIPPER_FIXEDPT           (10000000000000000)
-#define CLIPPER_METERS_PER_DEGREE (1110000000)
-#endif
 
 SGGeod SGGeod_snap( const SGGeod& in, double grid )
 {
@@ -369,16 +364,17 @@ bool intersection(const SGGeod &p0, const SGGeod &p1, const SGGeod& p2, const SG
     Segment_2 seg2( a2, b2 );
 
     CGAL::Object result = CGAL::intersection(seg1, seg2);
-    if (const CGAL::Point_2<Kernel> *ipoint = CGAL::object_cast<CGAL::Point_2<Kernel> >(&result)) {
+    const CGAL::Point_2<Kernel> *ipoint = CGAL::object_cast<CGAL::Point_2<Kernel> >(&result);
+    const CGAL::Segment_2<Kernel> *iseg = CGAL::object_cast<CGAL::Segment_2<Kernel> >(&result);
+    
+    if (ipoint) {
         // handle the point intersection case with *ipoint.
         return true;
+    } else if (iseg ) {
+        // handle the segment intersection case with *iseg.
+        return true;
     } else {
-        if (const CGAL::Segment_2<Kernel> *iseg = CGAL::object_cast<CGAL::Segment_2<Kernel> >(&result)) {
-            // handle the segment intersection case with *iseg.
-            return false;
-        } else {
-            // handle the no intersection case.
-            return false;
-        }
+        // handle the no intersection case.
+        return false;
     }
 }
\ No newline at end of file
diff --git a/src/Prep/DemChop/srtmchop.cxx b/src/Prep/DemChop/srtmchop.cxx
index 2f45fb6b..fe770a8f 100644
--- a/src/Prep/DemChop/srtmchop.cxx
+++ b/src/Prep/DemChop/srtmchop.cxx
@@ -148,15 +148,18 @@ bool TGSrtmTiff::open( const SGPath &f ) {
         
         cout << "Extracting " << file_name.str() << " to " << tmp_dir.path().str() << endl;
         string command = "unzip -d \"" + tmp_dir.path().str() + "\" " + file_name.base();
-        system( command.c_str() );
-
-        simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
-        BOOST_FOREACH(const SGPath& file, files) {
-            string ext = file.lower_extension();
-            if ( (ext == "tif") || (ext == "tiff") ) {
-                file_name = file;
-                break;
+        if ( system( command.c_str() ) != -1 ) {
+            simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
+            BOOST_FOREACH(const SGPath& file, files) {
+                string ext = file.lower_extension();
+                if ( (ext == "tif") || (ext == "tiff") ) {
+                    file_name = file;
+                    break;
+                }
             }
+        } else {
+            SG_LOG(SG_GENERAL, SG_ALERT, "Failed to issue system call " << command );
+            exit(1);            
         }
         
         remove_tmp_file = true;
diff --git a/src/Prep/Terra/GreedyInsert.h b/src/Prep/Terra/GreedyInsert.h
index 72f04991..4ae7217e 100644
--- a/src/Prep/Terra/GreedyInsert.h
+++ b/src/Prep/Terra/GreedyInsert.h
@@ -68,7 +68,7 @@ protected:
 
 public:
     GreedySubdivision(Map *map);
-    ~GreedySubdivision();
+    virtual ~GreedySubdivision();
 
     array2<char> is_used;
 
diff --git a/src/Prep/Terra/Subdivision.h b/src/Prep/Terra/Subdivision.h
index 338d83f0..1e65860a 100644
--- a/src/Prep/Terra/Subdivision.h
+++ b/src/Prep/Terra/Subdivision.h
@@ -21,6 +21,11 @@ public:
 	token = t;
 	reshape(e);
     }
+    
+    virtual ~Triangle()
+    {
+        
+    }
 
     Triangle *linkTo(Triangle *t) { next_face = t; return this; }
     Triangle *getLink() { return next_face; }
diff --git a/src/Prep/Terra/greedy.cc b/src/Prep/Terra/greedy.cc
index 999781b1..ee2e366b 100644
--- a/src/Prep/Terra/greedy.cc
+++ b/src/Prep/Terra/greedy.cc
@@ -74,8 +74,8 @@ inline int goal_not_met()
 {
     return
         ( mesh->maxError() > error_threshold &&
-          mesh->pointCount() < point_limit ) ||
-        mesh->pointCount() < min_points;
+          (int)mesh->pointCount() < point_limit ) ||
+          (int)mesh->pointCount() < min_points;
         
 }
 
diff --git a/src/Prep/TerraFit/terrafit.cc b/src/Prep/TerraFit/terrafit.cc
index d025e475..99c54838 100644
--- a/src/Prep/TerraFit/terrafit.cc
+++ b/src/Prep/TerraFit/terrafit.cc
@@ -91,7 +91,8 @@ public:
                 }
                 depth=32;
         }
-
+        virtual ~ArrayMap() {}
+        
         virtual Terra::real eval(int i, int j) {
                 return (Terra::real)array.get_array_elev(i,j);
         }