Using Script Properties

Some time ago in http://bbs.applescript.net/viewtopic.php?t=10363&highlight=duplicates , jj (one of the moderators here) illustrated a speed-up for dealing with elimination of duplicates in a list using script properties like this:

set x to {"a@a.e", "b@b.c", "d@a.h", "a@a.e"}

addr(x) --> {"a@a.e", "b@b.c", "d@a.h"}

to addr(l)
   script foo
      property foo2 : l
      property okAddresses : {}
   end script
   
   considering case
      repeat with i from 1 to count (foo's foo2)
         set x to ((foo's foo2)'s item i)
         if x is in foo's okAddresses then
         else
            set end of foo's okAddresses to x
         end if
      end repeat
   end considering
   foo's okAddresses
end addr

and I adapted the idea to several list manipulating scripts of my own because making the list to be manipulated a script property really does speed them up (as jj explains in the linked thread).

A question has arisen because in one script of mine a nested handler doesn’t work properly and I can’t figure out why. So, jj, when you have a handler which in turn calls two others in the same script document, should the script sub section defining list elements be in the parent or in the sub-handler that uses the variable (as I’ve got them)?

Problem: the first handler works properly, but the nested handler gives an error “Can’t get last item of {}” when the script is “sortProp”, the property is “property NL : {}” and the instruction is “set end of sortProp’s NL to item (LowItem - 1) of sortProp’s PL” where NL is the new list and PL is the old list. This same instruction works with different properties in the parent, so I’m thinking that there should only be one script … end script segment for all. True? I haven’t tried it because it would require some heavy rewriting and because I’d like to understand.

ADDENDUM: It appears from further experiments that if the script property route is to be taken, then the nested handlers must be without arguments to use the properties defined in the parent Script … end Script sequence. Clearly, I’m missing something about how this works.