further minor refactorings and clarifications to sqlalchemy code.

this now seems nice enough to look at.