Fix up potential overflows in size calculations by replacing