Refactored Matlab files