fix unsigned integer overflows 0 - 1