Fix a bug in overlapping intervals. Also, rename variable names to be more user friendly.