Fix for dcast segfault