Some SQLAlchemy session cleanup

Rebuilt #93 on development, then split out the plugin part.

This is the session handling cleanup. The point is to abstract any session
management away from the endpoints are using the data, and to
initiate a session per transaction rather than leaving one session open
for the lifetime of the server (the latter was causing concurrency issues
when different factories were accessing the session).

Now actually pulling to development. Third time's the charm.