Fix bug in cfg agent and other small fixes

Change-Id: Ic596b5d21f4b48b9c9c395b2120c121e0167f03e