Replace some casts