replaced c-style casts with static_cast and other initializations