Cleans up some of the local tensor code