     current = current + ((target - current) > 0 ? rate : - rate);
     delay(pause);
   }
+  current = target; // handle cases where target and rate aren't multiples of 255
+  analogWrite(pin, current);
   return current;
 }
 

  current = fade_to(current, 0xc0, 2, cfg->pin, 1);
  current = fade_to(current, 0x4, 2, cfg->pin, 1);
  delay(80); // fastest rate
  delay( (13 - cfg->tempo) * 15 );
  //delay(180);
  current = fade_to(current, 0xff, 2, cfg->pin, 1);
  current = fade_to(current, 0x00, 2, cfg->pin, 1);
  delay(214); // fastest rate
  delay( (13 - cfg->tempo) * 37 );
  //delay(420);

    digitalWrite(port[i].pin, LOW);
    if (port[i].effect == NONE)
      continue;
    light_threads[i] = createThreadFromHeap(32,
                                           20,
                                           effects_thread,
                                           &port[i]);
