Optimize esc removal code.