Adding middleware, cleaning up formatting.