delay() runs super fast unless I remove a while loop that never runs
I will add an official answer just so that others can see it if they run into similar problems.

The issue is with the int sequence[1000] array, which eats up 2,000 bytes of data memory. The Uno only has 2,048 bytes of data memory so the instability is due to this memory hog of an array. Use a smaller number of array entries or switch to char (if you can) to use half the bytes of an int.