Only record changes for dirtying commands.

Change-Id: I75edabdf3ff447fd15980a237f223f6da6b48b36