Fix some potential int overflows on 64-bit arch.