This needs to be reworked to deal with proxies