Better initialization of app and management of variables. More comments added. Changed a few variable names. Removed some redundant code recalculating default settings values