Bug fixes for parseFormula