changed ProcessFreeResources to do another null check in the nested loop and to print out information, note the TODO