Working version. Has auto minrange finding.
Removed drawing comments. Successfully fits the wrong peak.
Fancy is sortof working. Rest of functions untested.