TIDS (Tensor Internal Data Structure)

I messed something up in my previous PR and I don't understand how to get out of it.

Here is it agaian.