Solver and some helper functions written for DTI.  Testing now.