Better math error handling