Improving the stability of code - nulling pointer after freeing memory.