Got rid of some unnecessary static_pointer_casts.