fix unsigned integer overflow runtime errors