Memory leak fixes for insert/remove redirect functions