You might take a look at coverage_model.utils.fix_slice()  You look to be doing similar things, but that one's a little more comprehensive....which may also make it too heavy weight...comare/contrast...