analyzer warnings fixed
cleanup
renamed err macro to errN to reduce chance of clobbering some variable name