Updated to support general proxy mode.