GroupTracks.leave_indexes property only works for 'existing' g

So, I’ve made a lot of tools. PushBack and PushBackKeys might be two of my most used tools for myself. What worked before seems to not work properly anymore… the intended behaviour for PushBackKeys was the same as PushBack, namely, if the cursor (in Pattern Editor) is in a group track, and you call the pushback keys window, it would apply ‘groove’ / patterned delay values, to every track in the group. That’s why I added this piece of code in the beginning of the tool.

-- Track.track_index property  
local track_index_property = property(function(self)  
 for index, track in ipairs( do  
 if (rawequal(self, track)) then  
 return index  
renoise.Track.track_index = track_index_property  
renoise.GroupTrack.track_index = track_index_property  
-- GroupTrack.leaves_indexes property  
function find_leaves_indexes(self)  
 local list = table.create()  
 for _, t in ipairs(self.members) do  
 if t.type == 1 then  
 elseif t.type == 4 then  
 local sublist = find_leaves_indexes(t)  
 for i = 1, #sublist do  
 return list  
local grouptrack_leaves_indexes_property = property(find_leaves_indexes)  
renoise.GroupTrack.leaves_indexes = grouptrack_leaves_indexes_property  

This code is somewhat modified from what I have got in a suggestion from It-Alien. The problem is now, I think, that the leaves_indexes only get applied to existing groups, i.e. if I select three tracks and group them with ‘Add Selected Tracks to Group’ tool, the PBK tool won’t work, and doesn’t fire an error at all, for the created group track. Should I check within that last tool if the PBK tool is added and then explicitly add the leaves_indexes_property??

You nest two function into one call. At least this example shows pretty much why object oriented programming works so confusing.
For me this is hard to track without using the lua debug stepper that steps through your code line by line, and even with that, i can’t see your error.

It might have something to do now with the fact that I have this same code (properties/methods added to Renoise core Object types) running in multiple tools… Basement, Push Back and Push Back Keys I guess. So probably when the last one is loaded, it replaces the function, thus making it invisible to the previously loaded tools? Could that be it?