Added writeFile + freeMatrice function
 Added some corrections