implement removing of unused code from template