[#1] agent arg added; methods factored out; redundant comments removed