Optimized Math class