Fixed some problems with root finding.