Fix memory leaks in k_order_perturbation DLL