cherry pick the clean up middleware from the security branch