Optimize array functions
Merge pull request #1972 from sjinks/array-opt

Optimize array functions