Eliminate some reference cycles

Hi!
We're working on making Python garbage collector's life in our applications easier, one of the identified sources of frequently discarded object graphs with reference cycles is SQLAlchemy, I managed to find some low hanging fruits and modify the code, find the changes attached.

I left it split into individual commits for clarity - feel free to modify/squash/etc. I also left out unit tests as I'm not sure how should they be approached here.

Comments are welcome; please consider incorporate those changes in one form or another.