A number of minor fixes and corrections.  Now working more or less.
Needs clean up and parameteriztion.