Fixes to upgrade to SQLAlchemy 0.9