It occurs to me that Array.shift() is probably slow.