more for proxy support

Also moved code around so there is less waist.