   if (width > maxSize) return;
   
   int offset = speedMS > 0 ? millis() / speedMS : 0;
-  
-  for (int i = 0; i < PIXEL_COUNT; ++i) {
-    int colorIndex = ((i + offset) % (scheme.count * width)) / width;
+  int colorIndex = 0;
+  
+  for (uint8_t i = 0; i < PIXEL_COUNT; ++i) {
+    colorIndex = ((i + offset) % (scheme.count * width)) / width;
     strip.setPixelColor(i, scheme.colors[colorIndex].red, scheme.colors[colorIndex].green, scheme.colors[colorIndex].blue);
   }
   strip.show(); 
 }
+
 // Fill the dots one after the other with a color
 void colorWipe(uint32_t c, uint8_t wait) {
-  for(uint16_t i=0; i<strip.numPixels(); i++) {
+  #ifdef debug
+    Serial.print(F("colorWipe wait: ")); Serial.println(wait);
+  #endif
+  
+  for(uint8_t i=0; i < PIXEL_COUNT; i++) {
     strip.setPixelColor(i, c);
     strip.show();
+    if (checkServer()) {
+      return;
+    }
     delay(wait);
   }
 }
 
 void rainbows(uint8_t wait) {
   uint16_t i, j;
-
+  
+  #ifdef debug
+    Serial.print(F("rainbow wait: ")); Serial.println(wait);
+  #endif
+  
   for(j=0; j<256; j++) {
     for(i=0; i<PIXEL_COUNT; i++) {
       strip.setPixelColor(i, Wheel((i+j) & 255));
     }
     strip.show();
+    if (checkServer()) {
+      return;
+    }
     delay(wait);
   }
 }

  unsigned long time = millis();
  int offset = speedMS > 0 ? time / speedMS : 0;

  Color oldColor = gradientColor(scheme, range, gradRange, PIXEL_COUNT-1+offset);  
  for (int i = 0; i < PIXEL_COUNT; ++i) {
    Color currentColor = gradientColor(scheme, range, gradRange, i+offset);
    if (speedMS > 0) {
      // Blend old and current color based on time for smooth movement.
      strip.setPixelColor(i, map(time % speedMS, 0, speedMS, oldColor.red,   currentColor.red),
                             map(time % speedMS, 0, speedMS, oldColor.green, currentColor.green),
                             map(time % speedMS, 0, speedMS, oldColor.blue,  currentColor.blue));
    }
    else {
      // No animation, just use the current color. 

ColorScheme schemes[7] = { incandescent, rgb, christmas, hanukkah, kwanzaa, rainbow, fire };

// Enumeration of possible pattern types.
enum Pattern { BARS = 0, GRADIENT };

// Enumeration of possible animation types.
enum Animation { RAINBOWS = 2, RAINBOW_CYCLE, COLOR_WIPE, THEATER_CHASE, THEATER_CHASE_RAINBOW };

// Bar width values (in number of pixels/lights) for different size options.
int barWidthValues[3] = { 1,      // Small
