Use Matrix class to optimize matrix_manager