better error control for SNMP operations, code cleanup