Removes casts that are not needed any more