Fixed bug in overlapping segments, added massive optimization in finding empty segments