Fixed a variety of performance issues with arrays