Started to refactor/cleanup app.py and main.js