optimised code, unused code deleted