Added code to fix trace file and added comments