minor bugs fixed in loading previous stage matrices and writing CSV file