Fixing more typos on TextOptimizer

To Wuwei: it might me interesting to pay more attention to the types of
the variables, in particular when you're dealing with pointer types.
Also, if you're reusing code from other parts of the code, it is always
good to check the consistency of what you've written (see inv and
inverseOpt, line 56).