Another thread safety fix for TFormula

This is the same as pull request #24 but for v5-34-21