Tried to fix the matplotlib memory leak