MADS: Fix some memory leaks