 // buttons & switches do different things in different states
 enum doorStates { doorClosed, doorOpening, doorOpen, doorClosing, doorBlocked, doorBlockedPir, doorError } doorState;
 
-double drivePWM = 0;
+double drivePWM;
 const double drivePWMscale = 1; // fiddling aid, constant factor applied to calculated PWM value. TODO: update profile & remove
 
 // TODO: the timing system has some quirks. think again or document
 
 unsigned long lastMillis = 0; // last loop's millis() result
 
-unsigned long driveMillis = 0;
-unsigned long driveStepMillis = 0;
-unsigned long driveTotalMillis = 0;
+unsigned long driveMillis;
+unsigned long driveProfileMillis;
+unsigned long driveTotalMillis;
 
 const unsigned long openInterval = 3000; // ms before the door closes again, unless blocked by button
 unsigned long openMillis = 0;

      break;

    case doorBlockedPir:
      if (pirTrigger == LOW) {

// hold the door open if button pressed
// TODO: another possibility would be to fall-through to doorBlocked
// and close the door instead. which way is better?
if (swTrigger == LOW) {
  motorFree();
  debug(currentMillis, F("Button switch triggered - door blocked\r\n"));
  setLeds1(red, ledSolid);
  doorState = doorBlocked;
  swTrigger = HIGH;
  break;
}

        if (swBack == LOW) {
          debug(currentMillis, F("IR sensor LOW - door open\r\n"));
          openMillis = 0;

  switch(doorState) {
    case doorClosed:
      // wait until a button is pressed or the front switch opens
      if (swTrigger == LOW || swFront == HIGH) {
        if (swTrigger == LOW) {
          debug(currentMillis, F("Button switch triggered - opening door\r\n"));
          initDrive(backward, accelProfileHigh);
          swTrigger = HIGH; // re-arm swTrigger
        } else {
          // maybe someone tried to pull the door open
          // TODO: or the door slams too fast into the end-stop and rebounds. align profile & inertial reality
          debug(currentMillis, F("Front switch triggered - opening door\r\n"));
          initDrive(backward, accelProfileLow);
        }
        setLeds2(white, black, EXTRAPIX, ledBackward);
        doorState = doorOpening;
