Fix a nasty bug in constant folding that resulted in overflow in several scenarios