Get rid of a lot of reinterpret_casts