A......... [ZBX-8660] Fix possible unsafe array access and improve code layout.