Automatic cleanups

To make writing your plugin simpler, XD performs a number of automated cleanups after each plugin command finishes: