Not related to this pull request, but calling a virtual in state would likely to be quite a bit more efficient than a dynamic cast.  I'm not sure how speed critical this code is.