Minor changes, implementing meshgrid and writing the params out at the end of stage2.