Common: redefined math functions as templates

Also fixed Math::Clamp() (was broken all this time)