Added middleware.  Resolves issue #5