Adding traces and cleaning up output