Changed Matrix parameter to ref.