Fixes segfault when using non-director classes. Restores a dynamic_cast which was previously removed. The dynamic_cast is not needed for the swig_connect_director call ... we'll have to find another solution for #449 for Java. Closes #1184