Tightened up the code that does parameter estimation.