Factored */arr functions, added caching (which doesn't work well yet)