Added suggestions to compute a few global variables.
Organized functions into categories.