Most Tensor() constructors are no longer inlined.
Moved the allocation/referencing code out of RefPointer::pointer into RefPointer. Added a check to prevent problems when replacing a pointer with its own content -- formerly the pointer would be deallocated. Added tests for this bug.