Removing last actor

I am using the removeActor() function to remove an actor from the party during a battle. 


It works fine on all actors except the last one on the list, however long the list is. 


If there are three actors in the party, and I removeActor() the third actor, the actor disappears, but their name/hp/mp doesn't and the game hangs. It will not move to the next turn. 


If there are four actors, third actor removes just fine now, but the fourth causes the hang. 


I am using the following plugins:


YEP_coreengine


YEP_baseparamcontrol


YEP_battleenginecore


YEP_buffsstatescore


YEP_targetcore


YEP_X_selectcontrol


YEP_skillcore


YEP_autopassivestates


my own plugin that I made


Edit: I know specifically which plugin is causing the problem now. It is the battle engine core. If I turn it off, I can remove the last actor. 


Unfortunately I need that plugin, so getting rid of it is simply not an option.
All Actor Data inside the YEP_battleenginecore will set up at battle start.


When you remove an Actor after the battle start the info will still be there.


Just tell me at which point you execute the removeActor and i can help you.. i hope 😛  
I have a skill that can be executed during battle that will remove the actor. It works fine on actors in the battle, except the last one (bottom of the screen). 


More specifically, when the move is executed, a function that I made in my own plugin is called through one of yanflys' lunatic mode tags.


The <post damage eval> tag because the move can miss.

Original thread: https://forums.rpgmakerweb.com/threads/removing-last-actor.69523/