Removed uneeded type casts and replaced c-style type casts by C++ type casts.