Adding dimensions and piecewise

Note: This pull request contains the "minor bug fixes" pull request within it.

This adds support for dimensions for state variables as well as to suggestions I had for allowing piecewise math-inline expressions (borrowing MathML) and initial conditions for state variables.  Since the dimensions for state variables is likely to be less controversial than the other two I could separate them into different branches/pull-requests if you like.

Cheers,

Tom