All of the delay(0)s are to prevent the esps internal watchdog from triggering. Then the delay 0 is run it lets the wifi stack and other things happen in the background. It is important not to have tight loops with out a delay 0 otherwise it will crash and reboot.
Also can you highlight the lines of code you changed. I might need to add this to the touch set up code to make this some thing that the user can define.
http://esp8266basic.com
A BASIC interpreter for your ESP
Working now on Autodrop3d. A 3d printer with automatic part ejection system. https://autodrop3d.com