Added filtering of short segments.