Agent improvements and cleanup

Change-Id: I138b2d8575bedfb6ef778a5a9e0df1bb613e827f