Add a patch that works around the problematic dynamic cast