   {
     bigsum += voltageBins[i];
   }
-
-  // re-add our voltageEpsilon across all slots
-  bigsum += voltageEpsilon << AVERAGE_BINS_BITS;
 
   // Compute the average, scaled from ADC value to temperature.
   *averageval  = (float)(bigsum >> AVERAGE_BINS_BITS);

  if (currentVoltageBin < 0)
  {
    // special case: first time through.
    // Initialize our voltageEpsilon and the current voltage bin.
    voltageEpsilon = readval-127;
    currentVoltageBin = 0;
    #ifdef DEBUG
      Serial.print("getTemperature: voltageEpsilon initialized to ");
      Serial.println(voltageEpsilon);
    #endif
  }

  // Shift our readval by the voltageEpsilon, constrain to fit within a byte, then save to the array
  readval_shifted = (byte)constrain((readval - voltageEpsilon), 0, 255);
  voltageBins[currentVoltageBin] = readval_shifted;

  // Nudge voltageEpsilon as required to avoid overflow the next time around
  if (readval_shifted > 200)
  {
    voltageEpsilon += 1;
    #ifdef DEBUG
      Serial.print("getTemperature: voltageEpsilon increased to ");
      Serial.println(voltageEpsilon);
    #endif
  } else if (readval_shifted < 50)
  {
    voltageEpsilon -= 1;
    #ifdef DEBUG
      Serial.print("getTemperature: voltageEpsilon decreased to ");
      Serial.println(voltageEpsilon);
    #endif
  }

  // increment the current bin, but wrap if we're at the end

ColorValue current_color;
ColorValue new_color;
ColorName next_color;
int voltageBins[AVERAGE_BINS] = {0};
int currentVoltageBin = -1;
TemperatureRecord high_temp = {0.0, 0};
TemperatureRecord low_temp = {999.9, 0};

