fixed up bugs in app.py, also formatting.