Improvements for PMC math tool

Not to be merged yet.  Just for review.