merge DEPLOY and UPGRADE_AGENT; some minor cleanup

merge DEPLOY and UPGRADE_AGENT; some minor cleanup