Copied all the Google App script code into here to have a central repository