fix some leak of memory