MADS: Fix GCC warnings and memory leaks