Fix a bug in the optimization code
Fix a bug in the optimization code

A crash was fixed in d919200fe456d91da8ba4a73f946837d4105bb68, but this fix was incomplete and a logic error remained unfixed until now.

Davidebyzero/RegexMathEngine,Davidebyzero/RegexMathEngine