Hi
A bit of housekeeping first
Tuning idle is usually the first thing that's done when tuning. For this, you turn off all the the Whistles and Bells. As @psig suggests, you even turn off idle control.
So, housekeeping
Straighten out the wue slope.
You are using pin 4 for FP, This is fine (and not uncommon), but set VVT to pin 45. In effect swapping them. It's not good practice to have 2 features on the same pin, even if you are not using one of them.
Remove the conditions from the secondary tables until you are ready to use them (pin 51).
As you may see from this extract from the code, pin 51 is the Launch Control/Flat Shift pin.
You could have a poor connection on CLT, as when TPS increases, so on occasion, does CLT. The CLT ciircuit is about resistance and voltage dividers, so adding intermitant resistance here will give odd results.
Default pin out for your perusal and adding features.
Enjoy
case 3:
//Pin mappings as per the v0.4 shield
pinInjector1 = 8; //Output pin injector 1 is on
pinInjector2 = 9; //Output pin injector 2 is on
pinInjector3 = 10; //Output pin injector 3 is on
pinInjector4 = 11; //Output pin injector 4 is on
pinInjector5 = 12; //Output pin injector 5 is on
pinInjector6 = 50; //CAUTION: Uses the same as Coil 4 below.
pinCoil1 = 40; //Pin for coil 1
pinCoil2 = 38; //Pin for coil 2
pinCoil3 = 52; //Pin for coil 3
pinCoil4 = 50; //Pin for coil 4
pinCoil5 = 34; //Pin for coil 5 PLACEHOLDER value for now
pinTrigger = 19; //The CAS pin
pinTrigger2 = 18; //The Cam Sensor pin
pinTrigger3 = 3; //The Cam sensor 2 pin
pinTPS = A2;//TPS input pin
pinMAP = A3; //MAP sensor pin
pinIAT = A0; //IAT sensor pin
pinCLT = A1; //CLS sensor pin
pinO2 = A8; //O2 Sensor pin
pinBat = A4; //Battery reference voltage pin
pinDisplayReset = 48; // OLED reset pin
pinTachOut = 49; //Tacho output pin (Goes to ULN2803)
pinIdle1 = 5; //Single wire idle control
pinIdle2 = 6; //2 wire idle control
pinBoost = 7; //Boost control
pinVVT_1 = 4; //Default VVT output
pinVVT_2 = 48; //Default VVT2 output
pinFuelPump = 45; //Fuel pump output (Goes to ULN2803)
pinStepperDir = 16; //Direction pin for DRV8825 driver
pinStepperStep = 17; //Step pin for DRV8825 driver
pinStepperEnable = 24; //Enable pin for DRV8825
pinFan = 47; //Pin for the fan output (Goes to ULN2803)
pinLaunch = 51; //Can be overwritten below
pinFlex = 2; // Flex sensor (Must be external interrupt enabled)
pinResetControl = 43; //Reset control output
pinBaro = A5;
pinVSS = 20;
pinWMIEmpty = 46;
pinWMIIndicator = 44;
pinWMIEnabled = 42;