   bool success;
 
   if (base != EEPROM_PAGE0_BASE && base != EEPROM_PAGE1_BASE) {
-#ifdef SERIAL_DEBUG
-    Serial.println("Out of range erase at "+String(base,HEX));
-#endif
     return false;
   }
 

  uint32_t base = pageBases[currentPage];
  for (uint32_t offset = EEPROM_PAGE_SIZE-2 ; offset >= 4 ; offset-=2) {
    if (GET_BYTE(base+offset) == variable) {
#ifdef SERIAL_DEBUG
      Serial.println("Fetched "+String(variable,HEX)+" from "+String(base+offset,HEX)+" as "+String(GET_BYTE(base+offset+1),HEX));
#endif
      return GET_BYTE(base+offset+1);
    }
  }

#ifdef SERIAL_DEBUG
  Serial.println("Couldn't find "+String(variable,HEX));
#endif
  return -1;
}

static bool writeHalfWord(uint32_t address, uint16_t halfWord) {
  if (! ( EEPROM_PAGE0_BASE <= address && address+1 < EEPROM_PAGE0_BASE + EEPROM_PAGE_SIZE ) &&
     ! ( EEPROM_PAGE1_BASE <= address && address+1 < EEPROM_PAGE1_BASE + EEPROM_PAGE_SIZE ) ) {
#ifdef SERIAL_DEBUG
    Serial.println("Out of range write at "+String(address,HEX));
#endif
    return false;
  }
  
#ifdef SERIAL_DEBUG
//    Serial.println("Writing "+String(halfWord,HEX)+" at "+String(address,HEX));
#endif
  FLASH_Unlock();
  boolean success = FLASH_COMPLETE == FLASH_ProgramHalfWord(address, halfWord);
  FLASH_Lock();  

  else { // both pages are blank
    currentPage = 1;
  }
  invalid = false;
}

