[CTensorCoFi] Finally, no memory leak or memory corruption. Still need optimizations, after the million flags I had to put