Substituted [] access in loops with :get and :set

Fixed the performance problem referred to in the last pull request.