Comments added

Comments added to explain as many functions and variables as possible, to make code legible.