This area looks to be one of continuing glitches and my guess is that it's now a bit Heath Robinson in the guts of the code. Maybe the time has come to overhaul that part of the programming with a view to a fresh start?