fix dbwriter crash on stage_email call. move 'langContext' geration into a central location. closes #936