Replace C-style casts with C++-style casts everywhere