Encapsulate the common code in the phasertng wrapper
There is a lot of copied/paste code that could be encapsulated in functions as the private modes mostly are the same code except for the user phil string specifications. Creating general function and calling it within all the modes would be a good solutions to this.