Once the PCM is flashed, it will not revert back to stock. When you retune the truck you are not changing anything since the tune is already in place. What is happening though is that you are causing the PCM to enter into a learn mode. The next time it happens try pulling the number 10 fuse in the under hood fuse panel for twenty seconds and see if that makes it act like it does when you attempt to retune it, since that will also put the PCM into a relearn mode. There appears to be something in the system that is causing the power loss. It will require a scan tool capable of reading sensor outputs. The P0401 is being set by not having the EGR in the system. When the EGR is commanded to open on your truck the PCM looks for a temperature increase from the intake manifold temperature sensor. Since there is no EGR, no EGR flow, therefore no temperature increase, the P0401 code is set. It is also possible that that may be the issue. Anytime a EGR delete is done on an 05 or later truck, it should be programmed with a EGR delete tune.