Restructuring the code, moving to flask-sqlalchemy for ORM support.