Edited the MathAPI based on experiments from the Contingency branch.