Add function to destroy matrix and utilitary functions