Crash Fix

Fixed crash caused by foreach loop.  Calculator class for formulas.