Hi,
We faced the same issue. Partly probably code related, like most of the writers suggested.
We have also substituted the Mega by a Teensy 3.2. The rated clockspeed of the Mega is 16MHz and for the Teensy 3.2 72MHz.
The difference is speed was huge!