Implements is_canonical() for Pow and Add

And fixes a few bugs.