Fix some memory leaks in redirect plugin