Remove some type unsafe code