Lot of changes to support ip/hostname ranges at the correct places,
still needs some work.