Rather than delete code, try copying the code to a global purgatory variable and marking the code either "Full of Light"" (it has been used in over 100 programs without failings), "Observant" (passes all tests), "Sinful" (it has NOT been flawless), or "Condemned" (failed in more than one program, not suited for repair).
A monitor function ("PastorBob()"?) that searches for all code marked "sinful" and marks them for salvation would be the ideal.