Resolve integer narrowing and sign mismatch warnings.