I can only make a suggestion to eliminate the huge pile of global variable.
Add an array. Each box of the array can represent as a systemslot.
For example Array.at(0,0) can be seen as systemslotA
Array.at(0,1) as systemslotB etc.
You can store the Objects in it when the conditions are met.
Though, you will still have the long list with different actions
Array.at(0,0)= Object A - Do This
Array.at(0,1)= Object B - Do This
(...)
gl!