units: Expand into full basic arithmetic.

And restructure a bit to make things more readable and maintainable.