agent stopping logic changed + minor style fixes