Declare `i` before using in `optimizeFunction`
Add explicit replacement with original when cancelling
0.0.1