Changing transaction management to be compatible with SQLAlchemy 0.7.1