Found that the array search 'contains' was a major bottleneck.  The native indexOf is much faster...