Make some variables unsigned to avoid signed overflow warnings.