dynamic_cast<> with pointers instead of reference and compare against NU...

Rework the down cast to use dynami_cast<> on pointers + comparison against NULL instead of dynamic_cast on references + std::bad_cast catch.

This is faster and safer: 
1 comparison 
VS 
1 comparison and maybe (1 throw and 1 catch)

And this work around a bug in FreeBSD 9.1 related to std::bad_cast.