Changed (still ugly code) the way of determining external IP