Fix some types and casts
Fix inf value type