fixed minor bugs with tensors (still not all stuff done)