Tuning parameters, and lots of refactoring of code into separate Segmentation, PreProcessing modules to achieve it cleanly.