Problem with MIDI Effect Loop Controller

Hi Guys, beginner here. I have been trying to make a MIDI receiver that gets the MIDI signal from a DIY Guitar effect switcher, and using that MIDI information turns 8 loops (outputs) ON or OFF. This works more or less as an extension for the Guitar effect switcher board. It receives Program Change, Control Change, Note ON plus Velocity, Note OFF plus velocity. All MIDI types are sent with the same Channel number.
The outputs are ON when the MIDI messages received match the output number. If none does, then the output is OFF. Outputs 1 and 2 can be configured as Normal(MODE 1), momentary (MODE 3) or Latching (MODE 2). All the other outputs are MODE 1 only.
This does more or less work, but there are a few problems. The first one i would like to tackle is the fact that if I reboot the Guitar effect switcher, but not the receiver, or if i just turn the receiver ON before the guitar switcher, The Output switching will be sort of out of sync, meaning that i have to send the same preset twice for the correct outputs to turn ON. Sometimes this also happens when I change to another bank and back. I checked the Guitar effect switcher output in MidiOX, and it all looks normal. It sends only the 4 MIDI events that is supposed to send, and with the right values. Anyway, here is the code… I have no idea of what is going ON here. As I said, and as you can see on the code, I am a beginner.
The MIDI library is that one from FortySeven Effects. I am also getting other problems if I send the different MIDI types on different channels, but that the next problem to be solved… First i would like to solve this one… I will also make a video of the problem as it might help you understand what is happening… Thank you in advance for your valuable time helping me… Code is attached to this post.

MIDI_RX_AMP_More_MIDI_and_2_CHs_15_WORKING.ino (24.2 KB)