Apple Mail rule problems

For many years (since Eudora) I have been using automated methods to sort my incoming mail into the hierarchy of mailboxes on my Mac. I had originally set up my gmail account on Apple Mail as POP3 but during some upgrade or other it got changed to IMAP. When I started using an iPhone I found that the messages which had been moved to Mac local mailboxes were no longer visible on the iPhone Mail app. This was irritating but until recently I did nothing about it except shut down the Mac Apple Mail app if I was going to be away from base for a significant length of time. Recently I decided to tackle the issue and after quite a bit of testing I found that the appropriate Rules to use were:
Move message to gmail archive
Copy message to [local Mac mailbox]
Delete message (to remove it from my Mac inbox)
Stop processing rules
For some time I was confused by the fact that the rules are stored in the order they appear in the choice list, NOT the order I thought they should be executed - but the above sequence seemed to work fine and I could read all messages in the gmail archive folder on my iPhone.
However, today I find that quite a number of the rules (apparently at random) have got corrupted - both the Move and Copy operations are pointing the the gmail archive - with the result that the affected messages are not put in the right mailboxes and are not seen on my Mac except in the gmail archive mailbox.
I have nearly 300 Rules and I have now disabled them all and am relying on manual sorting on incoming mail.
Why should the rules have been corrupted? It appears to have happened after a restart.

in friendship