fix integer overflow bugs when uint is 32 bits