When you say optimisation what exactly do you mean ? Have set all the motor and switch pins so that everything works as it should and run the test which showed a flat line with no spikes and reported that it was excellent. It has occurred to me that the only change I made was to use a smaller usb keyboard so will revert back to my old one and see if that helps.