replaced C casts by c++ casts