Nowing that AOLserver sometimes is a moving target and taking into account that ns_info scheduled is undocumented I would opt for fixing ad_schedule_proc to store the schedule id in the NSV array. That said, I haven't looked at the code in detail, but I would be willing to take a glance at your solution.