Doesn't use scipy's optimize no more.