Initial efforts to use simpler files

Moving main functions out from the app.py

(so far only some global variables and OAuth objects have been moved).