Refactor Classes related to compute matrices