Refactor of .mat-file reading