Locking actor as party leader using Yanfly's Party System

Hey! So, I have a problem. My game has the protagonist start out as a peasant, with a sprite/face for it. This is actor 1. Shortly after starting, you choose one of four classes. Depending on which choice you make, actor 1 is replaced with actor 2, 3, 4 or 5. However, later on, when a second actor joins the party (actor 6), actor 6 is the party leader by default.

I tried locking the actor in place after the class selection in made, using a script call:

lock_actor(2)

lock_actor(3)

lock_actor(4)

lock_actor(5)

However, it didn't work - when actor 6 is added, he becomes party leader.

I found an edit to the script that is meant to fix the lock_actor command, which is editing line 392 of Yanfly's party system:

return unless $game_party.battle_members.include?(actor.id)
↓ (into)
return unless $game_party.battle_members.include?(actor)

However, it still isn't working. Any tips?
EDIT

Just seen that you have the fix that I was going to suggest.

If it's still not working, then I'm afraid I have no idea.
How are you replacing actor 1 with actor 2 - 5? Are you adding actor 2 - 5, then removing actor 1? If so the system is thinking that the leader slot is open, so when actor 6 is added, it is added to the leader slot. Try instead removing actor 1, then adding actor 2 - 5, then calling the lock command. It should work from there.

Also, note that the lock command locks them in their current position in the system, *not* as the party leader. The only way to lock them as the leader is to make sure they are added into slot 1, then locked.
Yes, I just checked - you're right, I had it adding 2-5 then removing 1. I'll swap that around and try again. Thanks! I assumed that as the only actor in the party, it was automatically placed in slot 1, so that didn't matter. 

EDIT: That was exactly the problem! Thank you so very much, I was going out of my head trying to figure out what was going on.

Original thread: https://forums.rpgmakerweb.com/threads/locking-actor-as-party-leader-using-yanflys-party-system.41572/