Fixed free errors and Added frees for the PathGrid, test.in has no memleaks