A bunch of fixes and added math panel

These are mostly changes that I've simply forgotten to push,
since the app is no longer being used. I'm pushing them for
posterity, in the event I return to this and polish it up at
some point.