Fix some issues involving plugin unloading.