Refactor proxy-enabled payload handling

This fixes a couple bugs and generally cleans up the proxy option parsing code. 
It looks like some of this is happening as part of #3632