replaced reinterpret_cast with static_cast where possible