fix some type conversion bugs