Add comments detailing what each of the functions in app.py should do.
Also moved / renamed several of the functions.