Fix proxy crash

I've fixed the bug indirectly by checking the proxy configuration. I think the proxy string 'host:port' is 'non standard', but OTOH, it is relatively easy to support.

The proxy code needs refactoring, so the current code is really a temporary solution until we get a proper configuration system for proxy.