FREEPBX-7406 lots of work to get this fixed but now it works as expected