Add static_casts<> everywhere for type-safe pointer conversion.