Switched DB backend to SQLAlchemy. Added tests.