Use a context manager (as per sqlalchemy manual) to automatically
close database session contexts when they go out of scope.

This stops connection pool exhaustion when many requests are made
quickly.

Also added a command line option to profile the server.