Fix up an integer overflow properly - cast was wrong