Free matrices
Fix the sigsegv at the end
Merge pull request #78 from leto/pr/free_matrices

Free matrices