First working/tested version of robustified finding minimum algorithm.