Just for the records, the problem was that I copied SendEmail.pm to SendEmail_Local.pm. In the "Local" copy I made my customization.
This is not a good idea because at the end of SendEmail.pm you find "RT::Base->_ImportOverlays();" so I gues this triggered an endless loop which most of the time works nevertheless but occasionally fails with "copy freed scalar panic" or "Scrip Prepare died" Now I just have the modified method in "Local" and it seems to work. cheers!