Improved tensor contraction and added multiple contractions