That is probably inevitable. In the case of longer clicks the “true” audio is missing - replaced with “click” noise. There is no way that an effect can accurately guess what audio should have been there. Most click repair algorithms guess at the correct waveform by either extrapolating the waveform from before/after the effect, or by simply reducing the level of the click. Either way the “true” waveform will not be accurately reproduced and most algorithms tend to reduce the high frequency content of the repaired section, causing the “plop” effect.
I agree, but as you no doubt discovered from your own programming efforts, it is extraordinarily difficult to accurately distinguish the difference between clicks caused by scratches and clicks that are pert of the music.
For really badly damaged sections, the EZ-Patch plug-in can be useful: EZ-Patch
There is also the PopMute effect New plug-in effect - PopMute (for a description of what this does and how it works you will need to read the topic).