Improvements to arithmetic functions