How get delay() to compile under S4 s.t. not interfere PWM pins 5,6

I'm encountering a bug from the use of delay() fcn. Currently, to get the core to compile, I've added:

#ifndef delay
#define delay( msec ) _delay_ms( msec )
#endif

which compiles and runs. Sorta.

How should I get delay() to compile such that it does not interfere with PWM on pins 5 and 6 (ie, the controls for stepper 2)?

It wasn't the delay. It was the library file for AFMotor.cpp. The enabling of the H bridges in AFStepper::AFStepper is followed by initialization of PWM, which disables the bridges. By copying the bridge enable lines, it works:

// enable both H bridges
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(5, HIGH); // copy this line
digitalWrite(6, HIGH); // and this line

// use PWM for microstepping support
// use PWM for microstepping support
initPWM3(1);
initPWM4(1);
setPWM3(255);
setPWM4(255);
digitalWrite(5, HIGH); // paste this line
digitalWrite(6, HIGH); // and this line

This is 'duh' code. Why did it work in the IDE? I will post this find to the folks who wrote the library file...

S4 ??