Initial fix to prevent serveral plugin crashes.
Further work required.
Fix #25292 Fix #25604 Fix #25051