Added support for middleware classes, and factories.