Lots of reorganization; make app.py work.