Fix subnet_lookup() for overlapping subnets. Needs rethinking.