updated matlab bindings to prevent memory leak