   Serial.begin(115200);
   ARM_DEMCR |= ARM_DEMCR_TRCENA;
   ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
-  fix = micros();
-  for (int i = 0; i < PROT; i++) protocols[i].protocol = 255;
+  for (int i = 0; i < PROT; i++) protocols[i].next = 255;
   for (int j = 0; j < CHAN; j++) channels[j].protocol = 255;
   running = 0;
-  errorcode = 0;
-  finished = false;
+}
+
+void turn_off(Channel *ci) {
+  Protocol *p = (protocols + ci->protocol);
+  if (p->i == 0) digitalWrite(ci->pin, LOW);
+  else digitalWrite(ci->pin, HIGH);
+}
+
+void turn_on(Channel *ci) {
+  Protocol *p = (protocols + ci->protocol);
+  if (p->i == 0) digitalWrite(ci->pin, HIGH);
+  else digitalWrite(ci->pin, LOW);
 }
 
 // Loop runs forever
 void loop() {
-  if (running > 0 && errorcode == 0) {
+  if (running > 0) {
     int now = micros();
     int delta = now - tick;
     tick = now;

            bool flipped = false;
            bool on = (ci->runlevel > 1);
            while (ci->yn.s < 0) {
              advance_from(&(ci->yn), on ? protocol[ci->protocol].n : protocol[ci->protocol].y);
              flipped = !flipped;
              on = !on;
            }

        if (ci->t.s < 0) {
          if (ci->runlevel == 3) turn_off(ci);
          ci->runlevel = 0;
          running -= 1;
          continue;   // CONTINUE WITH NEXT CHANNEL, THIS ONE IS DONE
        }
        else {
