Added save-all-vals instruction for calls to 'apply'

Previously, the save-vals i instruction was used but this caused some bugs when the i that should be used differed from the one in the trace