Fixed memory leak in function unpair