Torus algorithm implementation

contains all the methods of the central algorithm