Refactor proxy-enabled payload handling

This fixes a couple bugs and generally cleans up the proxy option parsing code. 
Possibly in a Rex::Socket utility class, but the callers are a mix of handlers and stager modules.