Cleaning up middleware