Properly implemented trc/grc and minor optimizations