Refactor/middlewares

Middleware changed to use an interface-led approach, also now API Definition can be extended without having to extend the core object. Certain configuration settings moved out where possible.