Corrected some bugs. Now also saves matfiles and figures with unique names according to input