This is a result of auditing the code for overflow issues at random places. None of this is critical but I think all of it should be fixed.
I know this touches “red” code. I double-checked and triple-checked this but I can understand if some of the changes are not desirable because they change well-tested code.
Best reviewed in individual commits.