   char memtype = getch();
   if (CRC_EOP != getch()) {
     error++;
-    Serial.print((char) STK_NOSYNC);
+    SERIAL.print((char) STK_NOSYNC);
     return;
   }
-  Serial.print((char) STK_INSYNC);
-  if (memtype == 'F') {
-    result = flash_read_page(length);
-  }
-  if (memtype == 'E') {
-    result = eeprom_read_page(length);
-  }
-  Serial.print(result);
-  return;
+  SERIAL.print((char) STK_INSYNC);
+  if (memtype == 'F') result = flash_read_page(length);
+  if (memtype == 'E') result = eeprom_read_page(length);
+  SERIAL.print(result);
 }
 
 void read_signature() {
   if (CRC_EOP != getch()) {
     error++;
-    Serial.print((char) STK_NOSYNC);
+    SERIAL.print((char) STK_NOSYNC);
     return;
   }
-  Serial.print((char) STK_INSYNC);
+  SERIAL.print((char) STK_INSYNC);
   uint8_t high = spi_transaction(0x30, 0x00, 0x00, 0x00);
-  Serial.print((char) high);
+  SERIAL.print((char) high);
   uint8_t middle = spi_transaction(0x30, 0x00, 0x01, 0x00);
-  Serial.print((char) middle);
+  SERIAL.print((char) middle);
   uint8_t low = spi_transaction(0x30, 0x00, 0x02, 0x00);
-  Serial.print((char) low);
-  Serial.print((char) STK_OK);
+  SERIAL.print((char) low);
+  SERIAL.print((char) STK_OK);
 }
 //////////////////////////////////////////
 //////////////////////////////////////////

    // this is how we can get back in sync
    case CRC_EOP:
      error++;
      Serial.print((char) STK_NOSYNC);
      break;

    // anything else we will return STK_UNKNOWN
    default:
      error++;
      if (CRC_EOP == getch()) {
        Serial.print((char)STK_UNKNOWN);
      } else {
        Serial.print((char)STK_NOSYNC);
      }
  }
}


// - The SPI functions herein were developed for the AVR910_ARD programmer
// - More information at http://code.google.com/p/mega-isp

#include "Arduino.h"
#undef SERIAL

// Use pin 10 to reset the target
#define RESET     10

