Improve math normalization

Fixes #741