changes to writeToR1(...) functions to facilitate output of final values.
Added MCMC functionality.