corrected a bug in reading matrices on MacOS (fgets) and cleaned a bit the code