cleaned up agents.lua, fixed error