Refactored arithmetic classes, improving performance and design