Changed memory free code