code cleaning, memory leak prevention