Trying to debug freeing of state memory