Fixed memory leak in SWIG interface