Lots of cleaning up, particularly in what is output to param file