Fixes various casts