some refactoring cleanup on StaticMiddleware.