Changed getting range keys so the first and last ranges are allowed to have empty first and last keys as appropriate