replaced all c-style casts by c++ casts