MV Character transformation image stays after character died.

So I did some tests around this bug and found that when the character transforms and dies in battle they keep the "battle image" they acquire after transforming.
If the rest of the party escapes, survives, etc. After the battle the image from the transformation stays on them even after they revived or reentered a battle.

It does revert if the character transforms again to the transformation and they "don't die".

I'm not sure how to fix this? I know it's something to check if the actor is dead
then return the image to default(3), but I'm not sure how to put that in the note.
I'm using a yanfly plugin to help.
( http://yanfly.moe/2016/07/06/tips-tricks-actor-transformations-rpg-maker-mv/ )

Transformation state's note info. sample is below:


-------------------------
<Custom Apply Effect>
// Check if user is an actor.
if (user.isActor()) {
// Archive the previous settings.
user._prevCharName = user._prevCharName || user._characterName;
user._prevCharIndex = user._prevCharIndex || user._characterIndex;
user._prevFaceName = user._prevFaceName || user._faceName;
user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;
user._prevBattlerName = user._prevBattlerName || user._battlerName;
// Check if the actor ID is 3.
if (user.actorId() === 3) {
// The filename of the character graphic without the file extension.
var charName = 'spriteoverworld';
// The index of the character graphic used.
var charIndex = 3;
// The filename of the face graphic without the file extension.
var faceName = 'FacesForPartyMembers1';
// The index of of the face graphic used.
var faceIndex = 2;
// The filename of the battler graphic without the file extension.
var battlerName = 'actor1_1';
}
// Changes the character image to the setting applied from above.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the setting applied from above.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the setting applied from above.
user.setBattlerImage(battlerName);
// Refreshes the user's appearance.
user.refresh();
}
</Custom Apply Effect>

<Custom Remove Effect>
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var faceName = user._prevFaceName;
var faceIndex = user._prevFaceIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityFaceName = undefined;
user._priorityFaceIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityBattlerName = undefined;
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();
</Custom Remove Effect>
Moved to: Plugin Support
Hi just bumping in hopes that someone will see this and know how to resolve it. I'd appreciate it very much if anyone is familiar with this plugin and how it can be fixed.

Original thread: https://forums.rpgmakerweb.com/threads/character-transformation-image-stays-after-character-died.134783/