remove some dynamic_cast code

dynamic_cast does a lookup every time, it's slower than just checking a member.