More refactoring of Torch functionality from QML to C++