Fix usual arithmetic conversion.

Bug pointed out by andrewchambers.
Add 'static' to local functions.