start of sqlalchemy refactoring