More refactoring to torch interfaces. Still not done