Refactor proxy-enabled payload handling

This fixes a couple bugs and generally cleans up the proxy option parsing code. 
Right now, proxy authentication is not implemented so ```PROXY_USERNAME``` and ```PROXY_PASSWORD``` won't be used.