Fix SQLAlchemy sessions.

This breaks a couple of other things, but I'll get to them later. SQLAlchemy sessions are now opened and closed on a per-route basis and automatically committed.