fixes to facilitate using agent_custid as custnum, RT#4190