fix some typcast issues