The attached script uses a switch with 3000 elements and it works fine.

Isolate your switch and figure out what's messed up.

Attached Files
bigswitch.c (9 downloads)