   }
 }
 
+bool validate_gps_buffer()
+{
+  byte_zero = 0;
+  for(i = gps_read_buffer.indexOf('$') + 1; i < gps_read_buffer.lastIndexOf('*'); i++)
+  {
+    byte_zero = byte_zero ^ gps_read_buffer.charAt(i);
+  }
+  if(gps_read_buffer.endsWith(String(byte_zero, HEX)))
+  {
+    return true;
+  }
+  #ifdef GPS_DEBUG_ON
+  debug_info("Bad GPS buffer: " + gps_read_buffer);
+  #endif
+  return false;  
+}
+
+bool validate_nmea_buffer()
+{
+  byte_zero = 0;
+  for(i = nmea_read_buffer.indexOf('$') + 1; i < nmea_read_buffer.lastIndexOf('*'); i++)
+  {
+    byte_zero = byte_zero ^ nmea_read_buffer.charAt(i);
+  }
+  if(nmea_read_buffer.endsWith(String(byte_zero, HEX)))
+  {
+    return true;
+  }
+  #ifdef NMEA_DEBUG_ON
+  debug_info("Bad NMEA buffer: " + nmea_read_buffer);
+  #endif
+  return false;  
+}
 
 
 void gps_read()

     int incoming_byte = Serial3.read();
     if(incoming_byte == '\n')
     {
       if(gps_read_buffer.indexOf("$GPRMC,") == 0)
       {
         #ifdef GPS_DEBUG_ON
         debug_info(F("--GPS BUF RMC--"));
         debug_info(gps_read_buffer);
         #endif
         push_out_nmea_sentence(false);
         parse_gps_buffer_as_rmc();
       }
       else if(gps_read_buffer.indexOf("$GPGGA,") == 0)
       {
         #ifdef GPS_DEBUG_ON
         debug_info(F("--GPS BUF GGA--"));
         debug_info(gps_read_buffer);
         #endif
         push_out_nmea_sentence(false);
         parse_gps_buffer_as_gga();
       }
       gps_read_buffer = "";
     }

      sog_start < 0     ||    sog_start >= (int) gps_read_buffer.length()     ||
      tmg_start < 0     ||    tmg_start >= (int) gps_read_buffer.length()     ||
      date_start < 0    ||    date_start >= (int) gps_read_buffer.length()    ||
      var_start < 0     ||    var_start >= (int) gps_read_buffer.length()     ||
      gps_read_buffer.lastIndexOf('$') > 0)
  {
      #ifdef GPS_DEBUG_ON
      debug_info(F("Bad RMC string"));
