Dynamic casts should be checked and the refcount might also do something here