Fix crash when reloading plugin