Minor modifications towards SQLAlchemy bug fix