Refactor primitive boxing to use the valueOf method instead of allocating a new Number object to convert primitives.