     }
     
     // 9600 NMEA is the default baud rate for Adafruit MTK GPS's
-    GPS.begin(9600);
+    gps->begin(9600);
     
-    // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
-    GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
-    // uncomment this line to turn on only the "minimum recommended" data
-    //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
     // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
-    // the parser doesn't care about other sentences at this time
+    // the parser doesn't care about other sentences at this time    
+    //gps->sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); // Turn on RMC (recommended minimum) and GGA (fix data) including altitude
+    gps->sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY); // Turn on only the "minimum recommended" data
     
-    // Set the update rate
-    GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
     // For the parsing code to work nicely and have time to sort thru the data, and
-    // print it out we don't suggest using anything higher than 1 Hz    
+    // print it out we don't suggest using anything higher than 1 Hz update rate
+    //gps->sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
+    gps->sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);   // 10 Hz update rate
+    
     delay(1000);
 }
 
-void log_data(float latitude, float longitude, float speed, float angle, float altitude, float voltage, float current) {
-    unsigned long time = millis();
-    if (logFile) {
-        logFile.print(time);
-        logFile.print(", ");
-        logFile.print(latitude, 8);
-        logFile.print(", ");
-        logFile.print(longitude, 8);
-        logFile.print(", ");
-        logFile.print(speed, 4);
-        logFile.print(", ");
-        logFile.print(angle, 4);
-        logFile.print(", ");
-        logFile.print(altitude, 4);
-        logFile.print(", ");
-        logFile.print(voltage, 4);
-        logFile.print(", ");
-        logFile.println(current, 4);
-        logFile.flush();
-    }
-
-    /*Serial.print("\nTime: ");
-    Serial.print(GPS.hour, DEC); Serial.print(':');
-    Serial.print(GPS.minute, DEC); Serial.print(':');
-    Serial.print(GPS.seconds, DEC); Serial.print('.');
-    Serial.println(GPS.milliseconds);
-    Serial.print("Date: ");
-    Serial.print(GPS.day, DEC); Serial.print('/');
-    Serial.print(GPS.month, DEC); Serial.print("/20");
-    Serial.println(GPS.year, DEC);
-    Serial.print("Fix: "); Serial.print((int)GPS.fix);
-    Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
-    Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
-
-    Serial.print(time);
-    Serial.print(", ");
-    Serial.print(latitude);
-    Serial.print(", ");
-    Serial.print(longitude);
-    Serial.print(", ");
-    Serial.print(speed);
-    Serial.print(", ");
-    Serial.print(altitude);
-    Serial.print(", ");
-    Serial.print(voltage);
-    Serial.print(", ");
-    Serial.println(current);*/
-}
-
 void loop() {
-    char c = GPS.read();
-    // if you want to debug, this is a good time to do it!
-    if ((c) && (GPSECHO))
-      Serial.write(c); 
+    // Read from GPS
+    char c = gps->read();
     
-    // if a sentence is received, we can check the checksum, parse it...
-    if (GPS.newNMEAreceived()) {    
-        if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
+    // If a GPS sentence is received, we can check the checksum and parse it...
+    if (gps->newNMEAreceived()) {    
+        if (!gps->parse(gps->lastNMEA()))   // this also sets the newNMEAreceived() flag to false
           return;  // we can fail to parse a sentence in which case we should just wait for another
     }
   

        float speed = 0.0;  // in knots
        float angle = 0.0;
        float altitude = 0.0;  // in meters
        if (GPS.fix) {
            latitude = GPS.latitude / 100.0;
            longitude = GPS.longitude / 100.0;
            speed = GPS.speed;
            angle = GPS.angle;
            altitude = GPS.altitude;
        }

        int voltsValue = analogRead(VOLTAGE_PIN);

#define VOLTAGE_PIN A2
#define CURRENT_PIN A5
#define GPSECHO false
#define STARTING_DELAY 5000
#define LOGGING_DELAY 100


Adafruit_GPS *gps;
uint32_t timer = millis();
File logFile;
char outputBuffer[80];


void setup() {
    SoftwareSerial gpsSerial(8, 7);
    gps = new Adafruit_GPS(&gpsSerial);
    
    // connect at 115200 so we can read the GPS fast enough
    Serial.begin(115200);
    delay(STARTING_DELAY);

    // Configure pins for reading
    pinMode(VOLTAGE_PIN, INPUT);
    pinMode(CURRENT_PIN, INPUT);

    // SD card: pin 10 for chip select, 11 for MOSI, 12 for MISO and 13 for SCK
    if (!SD.begin(10, 11, 12, 13)) {
        Serial.println("SD initialization failed!");
        while(1);
