Please note that the "volatile byte" arrays are separate from the "static byte" arrays even though they have the same name. The static ones exist only to the code inside check_switches(). All the other code uses the volatile ones. You should probably get rid of the static ones.