genericfunctions cleanup
cherrypicking from hierarchical
removed some other unused stuff
some random changes
some refactoring
minor changes
moved cr segmentation algorithm into seperate file
new file: segmentation_ms
merged master!