fixed critical bug with segments cleaning
Merge remote-tracking branch 'upstream/master'