Improved proxy handling and selection