Add more strict type checking

Base arithmetic function are now templates (to use float and int)
Some functions now use the most generic type.